add an init command

This commit is contained in:
Johann Dreo 2023-08-21 08:42:35 +02:00
commit bbee38b972
5 changed files with 49 additions and 14 deletions

View file

@ -61,3 +61,9 @@
{"description":"init command: add a command to initialize a local .task dir and\/or config file.s","entry":"20230815T174710Z","modified":"20230821T061754Z","priority":"M","status":"pending","uuid":"81fc6480-e8e7-4dd4-9f01-a00f34463135","tags":["feat"]}
{"description":"init command: add a command to initialize a local .task dir and\/or config file.s","entry":"20230815T174710Z","modified":"20230821T061804Z","priority":"M","start":"20230821T061804Z","status":"pending","uuid":"81fc6480-e8e7-4dd4-9f01-a00f34463135","tags":["feat"]}
{"description":"init command: add a command to initialize a local .task dir and\/or config file.s","entry":"20230815T174710Z","modified":"20230821T062005Z","priority":"M","status":"pending","uuid":"81fc6480-e8e7-4dd4-9f01-a00f34463135","tags":["feat"]}
{"description":"init command: add a command to initialize a local .task dir and\/or config file.s","entry":"20230815T174710Z","modified":"20230821T063638Z","priority":"M","start":"20230821T063638Z","status":"pending","uuid":"81fc6480-e8e7-4dd4-9f01-a00f34463135","tags":["feat"]}
{"description":"allow filters: when invoked with filtered command, execute, then display filtered export — or point to altered tasks?","entry":"20230821T064218Z","modified":"20230821T064218Z","status":"pending","uuid":"b2233e70-b1fd-41db-b240-0fc265e3406e","tags":["feat"]}
{"description":"init command: add a command to initialize a local .task dir and\/or config file.s","end":"20230821T064231Z","entry":"20230815T174710Z","modified":"20230821T064231Z","priority":"M","status":"completed","uuid":"81fc6480-e8e7-4dd4-9f01-a00f34463135","tags":["feat"]}
{"description":"allow filters: when invoked with filtered command, execute, then display filtered export — or point to altered tasks?","entry":"20230821T064218Z","modified":"20230821T064416Z","priority":"H","status":"pending","uuid":"b2233e70-b1fd-41db-b240-0fc265e3406e","tags":["feat"]}
{"description":"theme config: use taskwarrior theme config and extends from there.","entry":"20230819T190428Z","modified":"20230821T064435Z","priority":"H","status":"pending","uuid":"6b248843-1b11-487b-85e8-a96e668f6772","tags":["feat","themes"]}
{"description":"more themes","entry":"20230812T182344Z","modified":"20230821T064530Z","status":"pending","uuid":"9ee183d4-3413-4efa-ba68-10d709669c05","tags":["themes"]}

View file

@ -1,3 +1,4 @@
[description:"init command: add a command to initialize a local .task dir and\/or config file.s" end:"1692600151" entry:"1692121630" modified:"1692600151" priority:"M" status:"completed" tags:"feat" tags_feat:"x" uuid:"81fc6480-e8e7-4dd4-9f01-a00f34463135"]
[description:"find data updir: try to find .task on upper directories if not in the existing one" end:"1692598477" entry:"1691773581" modified:"1692598477" priority:"H" status:"completed" tags:"data,feat" tags_data:"x" tags_feat:"x" uuid:"b4ee0b55-0bb3-4a2f-b7c5-87cd70dd0ff0"]
[description:"screenshots: to be added to the README on Github." end:"1692546052" entry:"1692538594" modified:"1692546052" status:"completed" tags:"website" tags_website:"x" uuid:"b5f1d2b6-9e2f-458f-afab-880c52121c82"]
[description:"config: handle config files from taskwarrior first" end:"1692471959" entry:"1691773951" modified:"1692471959" status:"completed" tags:"feat" tags_feat:"x" uuid:"4d822c4a-d51e-4992-8a22-6e0167ac197a"]

View file

@ -1,9 +1,9 @@
[description:"semantic tags : allow tags starting with a hash to refer to a github issue or PR" entry:"1691773642" modified:"1692121563" priority:"L" status:"pending" tags:"feat" tags_feat:"x" uuid:"06cf70a9-4f0e-4b32-b7bb-d1799803665c"]
[description:"hide old done tasks: Hide tasks with last status that haven t been touched since a long time." entry:"1691773751" modified:"1692122496" priority:"M" status:"pending" tags:"feat" tags_feat:"x" uuid:"e18707b4-304d-41f3-8504-89476cd796f5"]
[description:"fix escaped add: when passing add with escapable characters, bug ensues." entry:"1691774077" modified:"1691774077" status:"pending" tags:"bug" tags_bug:"x" uuid:"79e1ba11-15ae-489f-9868-ab6adea40a91"]
[description:"more themes" entry:"1691864624" modified:"1691990020" start:"1691990020" status:"pending" tags:"themes" tags_themes:"x" uuid:"9ee183d4-3413-4efa-ba68-10d709669c05"]
[description:"init command: add a command to initialize a local .task dir and\/or config file.s" entry:"1692121630" modified:"1692598805" priority:"M" status:"pending" tags:"feat" tags_feat:"x" uuid:"81fc6480-e8e7-4dd4-9f01-a00f34463135"]
[description:"more themes" entry:"1691864624" modified:"1692600330" status:"pending" tags:"themes" tags_themes:"x" uuid:"9ee183d4-3413-4efa-ba68-10d709669c05"]
[description:"colored panels: allow selecting a different swatch for each &open;sub&close;panel" entry:"1692122434" modified:"1692122452" priority:"M" status:"pending" tags:"feat,themes" tags_feat:"x" tags_themes:"x" uuid:"ca17838d-958f-498b-bff5-a24576820ae7"]
[description:"handle prompts: for some commands like delete, taskwarrior setup an interactive prompt, which needs to be handled." entry:"1692122614" modified:"1692122614" status:"pending" tags:"bug" tags_bug:"x" uuid:"e2480c4b-4c73-4d03-8568-82f14ade7b38"]
[description:"semantic colors: allow coloring by values, not just fields." entry:"1692255328" modified:"1692255328" status:"pending" tags:"feat,themes" tags_feat:"x" tags_themes:"x" uuid:"1a5aab4a-0c2b-444f-9259-6eddc29b9791"]
[description:"theme config: use taskwarrior theme config and extends from there." entry:"1692471868" modified:"1692471868" status:"pending" tags:"feat,themes" tags_feat:"x" tags_themes:"x" uuid:"6b248843-1b11-487b-85e8-a96e668f6772"]
[description:"theme config: use taskwarrior theme config and extends from there." entry:"1692471868" modified:"1692600275" priority:"H" status:"pending" tags:"feat,themes" tags_feat:"x" tags_themes:"x" uuid:"6b248843-1b11-487b-85e8-a96e668f6772"]
[description:"allow filters: when invoked with filtered command, execute, then display filtered export — or point to altered tasks?" entry:"1692600138" modified:"1692600256" priority:"H" status:"pending" tags:"feat" tags_feat:"x" uuid:"b2233e70-b1fd-41db-b240-0fc265e3406e"]

View file

@ -225,3 +225,26 @@ time 1692598805
old [description:"init command: add a command to initialize a local .task dir and\/or config file.s" entry:"1692121630" modified:"1692598684" priority:"M" start:"1692598684" status:"pending" tags:"feat" tags_feat:"x" uuid:"81fc6480-e8e7-4dd4-9f01-a00f34463135"]
new [description:"init command: add a command to initialize a local .task dir and\/or config file.s" entry:"1692121630" modified:"1692598805" priority:"M" status:"pending" tags:"feat" tags_feat:"x" uuid:"81fc6480-e8e7-4dd4-9f01-a00f34463135"]
---
time 1692599798
old [description:"init command: add a command to initialize a local .task dir and\/or config file.s" entry:"1692121630" modified:"1692598805" priority:"M" status:"pending" tags:"feat" tags_feat:"x" uuid:"81fc6480-e8e7-4dd4-9f01-a00f34463135"]
new [description:"init command: add a command to initialize a local .task dir and\/or config file.s" entry:"1692121630" modified:"1692599798" priority:"M" start:"1692599798" status:"pending" tags:"feat" tags_feat:"x" uuid:"81fc6480-e8e7-4dd4-9f01-a00f34463135"]
---
time 1692600138
new [description:"allow filters: when invoked with filtered command, execute, then display filtered export — or point to altered tasks?" entry:"1692600138" modified:"1692600138" status:"pending" tags:"feat" tags_feat:"x" uuid:"b2233e70-b1fd-41db-b240-0fc265e3406e"]
---
time 1692600151
old [description:"init command: add a command to initialize a local .task dir and\/or config file.s" entry:"1692121630" modified:"1692599798" priority:"M" start:"1692599798" status:"pending" tags:"feat" tags_feat:"x" uuid:"81fc6480-e8e7-4dd4-9f01-a00f34463135"]
new [description:"init command: add a command to initialize a local .task dir and\/or config file.s" end:"1692600151" entry:"1692121630" modified:"1692600151" priority:"M" status:"completed" tags:"feat" tags_feat:"x" uuid:"81fc6480-e8e7-4dd4-9f01-a00f34463135"]
---
time 1692600256
old [description:"allow filters: when invoked with filtered command, execute, then display filtered export — or point to altered tasks?" entry:"1692600138" modified:"1692600138" status:"pending" tags:"feat" tags_feat:"x" uuid:"b2233e70-b1fd-41db-b240-0fc265e3406e"]
new [description:"allow filters: when invoked with filtered command, execute, then display filtered export — or point to altered tasks?" entry:"1692600138" modified:"1692600256" priority:"H" status:"pending" tags:"feat" tags_feat:"x" uuid:"b2233e70-b1fd-41db-b240-0fc265e3406e"]
---
time 1692600275
old [description:"theme config: use taskwarrior theme config and extends from there." entry:"1692471868" modified:"1692471868" status:"pending" tags:"feat,themes" tags_feat:"x" tags_themes:"x" uuid:"6b248843-1b11-487b-85e8-a96e668f6772"]
new [description:"theme config: use taskwarrior theme config and extends from there." entry:"1692471868" modified:"1692600275" priority:"H" status:"pending" tags:"feat,themes" tags_feat:"x" tags_themes:"x" uuid:"6b248843-1b11-487b-85e8-a96e668f6772"]
---
time 1692600330
old [description:"more themes" entry:"1691864624" modified:"1691990020" start:"1691990020" status:"pending" tags:"themes" tags_themes:"x" uuid:"9ee183d4-3413-4efa-ba68-10d709669c05"]
new [description:"more themes" entry:"1691864624" modified:"1692600330" status:"pending" tags:"themes" tags_themes:"x" uuid:"9ee183d4-3413-4efa-ba68-10d709669c05"]
---

View file

@ -16,6 +16,7 @@ from rich.columns import Columns
error_codes = {
"NO_DATA_FILE": 100,
"CANNOT_INIT": 200,
}
@ -385,10 +386,10 @@ class group:
return groups
def call_taskwarrior(args:list[str] = ['export']) -> str:
def call_taskwarrior(args:list[str] = ['export'], taskfile = ".task") -> str:
# Local file.
env = os.environ.copy()
env["TASKDATA"] = ".task" # FIXME handle updir
env["TASKDATA"] = taskfile
cmd = ['task'] + args
try:
@ -407,8 +408,8 @@ def call_taskwarrior(args:list[str] = ['export']) -> str:
return out.decode('utf-8')
def get_data():
out = call_taskwarrior(['export'])
def get_data(taskfile):
out = call_taskwarrior(['export'], taskfile)
try:
jdata = json.loads(out)
except json.decoder.JSONDecodeError as exc:
@ -686,19 +687,23 @@ if __name__ == "__main__":
cmd = sys.argv[1:]
# TODO add an init command to create config and task files.
#if cmd[0] == "init":
if len(cmd) == 1 and cmd[0] == "init":
try:
os.mkdir(".task")
except Exception as err:
error("CANNOT_INIT", f"Cannot init task database here: {err}")
else:
print("Empty taskwarrior database initialized in", pathlib.Path.cwd())
sys.exit(0)
# First pass arguments to taskwarrior and let it do its magic.
out = call_taskwarrior(cmd)
out = call_taskwarrior(cmd, taskfile)
if "Description" not in out:
print(out.strip())
touched = parse_touched(out)
# print("Touched:",touched)
# Then get the resulting data.
jdata = get_data()
# Then call again to get the resulting data.
jdata = get_data(taskfile)
# print(json.dumps(jdata, indent=4))
list_separator = ","