From 4a25717f2ac5fda192fc6878dcd7a45161271c40 Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 15 Aug 2023 20:05:01 +0200 Subject: [PATCH] add optional subgrouping --- .task/backlog.data | 11 +++++++++++ .task/completed.data | 1 + .task/pending.data | 13 ++++++++----- .task/undo.data | 40 ++++++++++++++++++++++++++++++++++++++++ taskwarrior-deluxe.py | 26 ++++++++++++++++++++++---- 5 files changed, 82 insertions(+), 9 deletions(-) diff --git a/.task/backlog.data b/.task/backlog.data index 1552eea..c86c054 100644 --- a/.task/backlog.data +++ b/.task/backlog.data @@ -29,3 +29,14 @@ {"description":"show done: display completed tasks during some days after their completion, but not after","entry":"20230814T051438Z","modified":"20230814T051936Z","status":"pending","uuid":"18b8f46c-3498-4e75-8945-b578beaf29bc","tags":["feat"]} {"description":"show done: display completed tasks during some days after their completion, but not after","entry":"20230814T051438Z","modified":"20230814T052002Z","status":"pending","uuid":"18b8f46c-3498-4e75-8945-b578beaf29bc","tags":["bug","feat"]} {"description":"show done: display completed tasks during some days after their completion, but not after","entry":"20230814T051438Z","modified":"20230814T052015Z","status":"pending","uuid":"18b8f46c-3498-4e75-8945-b578beaf29bc","tags":["feat"]} +{"description":"find data updir: try to find .task on upper directories if not in the existing one","entry":"20230811T170621Z","modified":"20230815T174517Z","priority":"H","status":"pending","uuid":"b4ee0b55-0bb3-4a2f-b7c5-87cd70dd0ff0","tags":["data","feat"]} +{"description":"semantic tags : allow tags starting with a hash to refer to a github issue or PR","entry":"20230811T170722Z","modified":"20230815T174603Z","priority":"L","status":"pending","uuid":"06cf70a9-4f0e-4b32-b7bb-d1799803665c","tags":["feat"]} +{"description":"init command: add a command to initialize a local .task dir and\/or config file.s","entry":"20230815T174710Z","modified":"20230815T174710Z","priority":"M","status":"pending","uuid":"81fc6480-e8e7-4dd4-9f01-a00f34463135","tags":["feat"]} +{"description":"colored panels: allow selecting a different swatch for each [sub]panel","entry":"20230815T180034Z","modified":"20230815T180034Z","status":"pending","uuid":"ca17838d-958f-498b-bff5-a24576820ae7","tags":["feat","themes"]} +{"description":"colored panels: allow selecting a different swatch for each [sub]panel","entry":"20230815T180034Z","modified":"20230815T180052Z","priority":"M","status":"pending","uuid":"ca17838d-958f-498b-bff5-a24576820ae7","tags":["feat","themes"]} +{"description":"sort by urgency","entry":"20230811T170942Z","modified":"20230815T180125Z","priority":"H","status":"pending","uuid":"4f041f52-739a-4aca-94e6-164f43e61866","tags":["feat"]} +{"description":"hide old done tasks: Hide tasks with last status that haven t been touched since a long time.","entry":"20230811T170911Z","modified":"20230815T180136Z","priority":"M","status":"pending","uuid":"e18707b4-304d-41f3-8504-89476cd796f5","tags":["feat"]} +{"description":"show done: display completed tasks during some days after their completion, but not after","end":"20230815T180236Z","entry":"20230814T051438Z","modified":"20230815T180241Z","status":"deleted","uuid":"18b8f46c-3498-4e75-8945-b578beaf29bc","tags":["feat"]} +{"description":"handle prompts: for some commands like delete, taskwarrior setup an interactive prompt, which needs to be handled.","entry":"20230815T180334Z","modified":"20230815T180334Z","status":"pending","uuid":"e2480c4b-4c73-4d03-8568-82f14ade7b38","tags":["bug"]} +{"description":"subgrouping: allow to add another sectionning, e.g. based on priority.","entry":"20230815T180428Z","modified":"20230815T180428Z","status":"pending","uuid":"9dc6d43a-b316-4417-ad2a-e47b8a5ddc7a","tags":["feat"]} +{"description":"subgrouping: allow to add another sectionning, e.g. based on priority.","entry":"20230815T180428Z","modified":"20230815T180440Z","start":"20230815T180440Z","status":"pending","uuid":"9dc6d43a-b316-4417-ad2a-e47b8a5ddc7a","tags":["feat"]} diff --git a/.task/completed.data b/.task/completed.data index f43089d..c0a1a06 100644 --- a/.task/completed.data +++ b/.task/completed.data @@ -1 +1,2 @@ +[description:"show done: display completed tasks during some days after their completion, but not after" end:"1692122556" entry:"1691990078" modified:"1692122561" status:"deleted" tags:"feat" tags_feat:"x" uuid:"18b8f46c-3498-4e75-8945-b578beaf29bc"] [description:"styling: apply configurable styles to each field and state with semantics" end:"1691990004" entry:"1691774377" modified:"1691990004" status:"completed" tags:"feat" tags_feat:"x" uuid:"17819637-4f4a-4e46-8622-12d8243c54da"] diff --git a/.task/pending.data b/.task/pending.data index 19c04f8..4325dd8 100644 --- a/.task/pending.data +++ b/.task/pending.data @@ -1,8 +1,11 @@ -[description:"find data updir: try to find .task on upper directories if not in the existing one" entry:"1691773581" modified:"1691773581" status:"pending" tags:"data,feat" tags_data:"x" tags_feat:"x" uuid:"b4ee0b55-0bb3-4a2f-b7c5-87cd70dd0ff0"] -[description:"semantic tags : allow tags starting with a hash to refer to a github issue or PR" entry:"1691773642" modified:"1691774223" 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:"1691773751" status:"pending" tags:"feat" tags_feat:"x" uuid:"e18707b4-304d-41f3-8504-89476cd796f5"] -[description:"sort by urgency" entry:"1691773782" modified:"1691773782" status:"pending" tags:"feat" tags_feat:"x" uuid:"4f041f52-739a-4aca-94e6-164f43e61866"] +[description:"find data updir: try to find .task on upper directories if not in the existing one" entry:"1691773581" modified:"1692121517" priority:"H" status:"pending" tags:"data,feat" tags_data:"x" tags_feat:"x" uuid:"b4ee0b55-0bb3-4a2f-b7c5-87cd70dd0ff0"] +[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:"sort by urgency" entry:"1691773782" modified:"1692122485" priority:"H" status:"pending" tags:"feat" tags_feat:"x" uuid:"4f041f52-739a-4aca-94e6-164f43e61866"] [description:"config file.s" entry:"1691773951" modified:"1691773951" status:"pending" tags:"feat" tags_feat:"x" uuid:"4d822c4a-d51e-4992-8a22-6e0167ac197a"] [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:"show done: display completed tasks during some days after their completion, but not after" entry:"1691990078" modified:"1691990415" status:"pending" tags:"feat" tags_feat:"x" uuid:"18b8f46c-3498-4e75-8945-b578beaf29bc"] +[description:"init command: add a command to initialize a local .task dir and\/or config file.s" entry:"1692121630" modified:"1692121630" priority:"M" status:"pending" tags:"feat" tags_feat:"x" uuid:"81fc6480-e8e7-4dd4-9f01-a00f34463135"] +[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:"subgrouping: allow to add another sectionning, e.g. based on priority." entry:"1692122668" modified:"1692122680" start:"1692122680" status:"pending" tags:"feat" tags_feat:"x" uuid:"9dc6d43a-b316-4417-ad2a-e47b8a5ddc7a"] diff --git a/.task/undo.data b/.task/undo.data index 8e7e897..a124f22 100644 --- a/.task/undo.data +++ b/.task/undo.data @@ -113,3 +113,43 @@ time 1691990415 old [description:"show done: display completed tasks during some days after their completion, but not after" entry:"1691990078" modified:"1691990402" status:"pending" tags:"bug,feat" tags_bug:"x" tags_feat:"x" uuid:"18b8f46c-3498-4e75-8945-b578beaf29bc"] new [description:"show done: display completed tasks during some days after their completion, but not after" entry:"1691990078" modified:"1691990415" status:"pending" tags:"feat" tags_feat:"x" uuid:"18b8f46c-3498-4e75-8945-b578beaf29bc"] --- +time 1692121517 +old [description:"find data updir: try to find .task on upper directories if not in the existing one" entry:"1691773581" modified:"1691773581" status:"pending" tags:"data,feat" tags_data:"x" tags_feat:"x" uuid:"b4ee0b55-0bb3-4a2f-b7c5-87cd70dd0ff0"] +new [description:"find data updir: try to find .task on upper directories if not in the existing one" entry:"1691773581" modified:"1692121517" priority:"H" status:"pending" tags:"data,feat" tags_data:"x" tags_feat:"x" uuid:"b4ee0b55-0bb3-4a2f-b7c5-87cd70dd0ff0"] +--- +time 1692121563 +old [description:"semantic tags : allow tags starting with a hash to refer to a github issue or PR" entry:"1691773642" modified:"1691774223" status:"pending" tags:"feat" tags_feat:"x" uuid:"06cf70a9-4f0e-4b32-b7bb-d1799803665c"] +new [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"] +--- +time 1692121630 +new [description:"init command: add a command to initialize a local .task dir and\/or config file.s" entry:"1692121630" modified:"1692121630" priority:"M" status:"pending" tags:"feat" tags_feat:"x" uuid:"81fc6480-e8e7-4dd4-9f01-a00f34463135"] +--- +time 1692122434 +new [description:"colored panels: allow selecting a different swatch for each &open;sub&close;panel" entry:"1692122434" modified:"1692122434" status:"pending" tags:"feat,themes" tags_feat:"x" tags_themes:"x" uuid:"ca17838d-958f-498b-bff5-a24576820ae7"] +--- +time 1692122452 +old [description:"colored panels: allow selecting a different swatch for each &open;sub&close;panel" entry:"1692122434" modified:"1692122434" status:"pending" tags:"feat,themes" tags_feat:"x" tags_themes:"x" uuid:"ca17838d-958f-498b-bff5-a24576820ae7"] +new [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"] +--- +time 1692122485 +old [description:"sort by urgency" entry:"1691773782" modified:"1691773782" status:"pending" tags:"feat" tags_feat:"x" uuid:"4f041f52-739a-4aca-94e6-164f43e61866"] +new [description:"sort by urgency" entry:"1691773782" modified:"1692122485" priority:"H" status:"pending" tags:"feat" tags_feat:"x" uuid:"4f041f52-739a-4aca-94e6-164f43e61866"] +--- +time 1692122496 +old [description:"hide old done tasks: Hide tasks with last status that haven t been touched since a long time." entry:"1691773751" modified:"1691773751" status:"pending" tags:"feat" tags_feat:"x" uuid:"e18707b4-304d-41f3-8504-89476cd796f5"] +new [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"] +--- +time 1692122561 +old [description:"show done: display completed tasks during some days after their completion, but not after" entry:"1691990078" modified:"1691990415" status:"pending" tags:"feat" tags_feat:"x" uuid:"18b8f46c-3498-4e75-8945-b578beaf29bc"] +new [description:"show done: display completed tasks during some days after their completion, but not after" end:"1692122556" entry:"1691990078" modified:"1692122561" status:"deleted" tags:"feat" tags_feat:"x" uuid:"18b8f46c-3498-4e75-8945-b578beaf29bc"] +--- +time 1692122614 +new [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"] +--- +time 1692122668 +new [description:"subgrouping: allow to add another sectionning, e.g. based on priority." entry:"1692122668" modified:"1692122668" status:"pending" tags:"feat" tags_feat:"x" uuid:"9dc6d43a-b316-4417-ad2a-e47b8a5ddc7a"] +--- +time 1692122680 +old [description:"subgrouping: allow to add another sectionning, e.g. based on priority." entry:"1692122668" modified:"1692122668" status:"pending" tags:"feat" tags_feat:"x" uuid:"9dc6d43a-b316-4417-ad2a-e47b8a5ddc7a"] +new [description:"subgrouping: allow to add another sectionning, e.g. based on priority." entry:"1692122668" modified:"1692122680" start:"1692122680" status:"pending" tags:"feat" tags_feat:"x" uuid:"9dc6d43a-b316-4417-ad2a-e47b8a5ddc7a"] +--- diff --git a/taskwarrior-deluxe.py b/taskwarrior-deluxe.py index 52db20d..7741992 100755 --- a/taskwarrior-deluxe.py +++ b/taskwarrior-deluxe.py @@ -76,7 +76,7 @@ class task: val = task[key] segment = f"{key}: " if type(val) == str: - segments.append(rich.text.Text(segment+t, style=key)) + segments.append(rich.text.Text(segment+val, style=key)) elif type(val) == list: # FIXME Columns does not fit. # g = Columns([f"+{t}" for t in val], expand = False) @@ -289,9 +289,17 @@ class Grouper: groups[ task[self.field] ].append(task) else: groups[ task[self.field] ] = [task] + else: + if "" in groups: + groups[ "" ].append( task ) + else: + groups[ "" ] = [task] return groups class group: + class Field(Grouper): + pass + class Status(Grouper): def __init__(self): super().__init__("status") @@ -312,6 +320,7 @@ class group: return groups + def call_taskwarrior(args:list[str] = ['export']) -> str: # Local file. env = os.environ.copy() @@ -503,7 +512,7 @@ if __name__ == "__main__": formatter_class=argparse.ArgumentDefaultsHelpFormatter, ) - parser.add_argument("-s", "--show", metavar="columns", type=str, default="id,description,tags", nargs=1, + parser.add_argument("-s", "--show", metavar="columns", type=str, default="id,priority,description,tags", nargs=1, help="Ordered list of columns to show.") @@ -524,6 +533,8 @@ if __name__ == "__main__": choices = get_layouts('stack').keys(), help="Layout managing stacks.") layouts_grp.add_argument('-c', '--layout-sections', metavar='NAME', type=str, default='Horizontal', choices = get_layouts('sections').keys(), help="Layout managing sections.") + layouts_grp.add_argument('-C', '--layout-subsections', metavar='NAME', type=str, default=None, + choices = get_layouts('sections').keys(), help="Layout managing sub-sections.") layouts_grp.add_argument('-T', '--swatch', metavar='NAME', type=str, default='none', choices = get_swatches().keys(), help="Color chart.") @@ -570,8 +581,15 @@ if __name__ == "__main__": stacker = layouts['stack'][asked.layout_stack](tasker) group_by_status = group.Status() - sort_on_values = sort.OnValues(["pending","started","completed"]) - sectioner = layouts['sections'][asked.layout_sections](stacker, sort_on_values, group_by_status) + group_by_priority = group.Field("priority") + sort_on_status_values = sort.OnValues(["pending","started","completed"]) + sort_on_priority_values = sort.OnValues(["H","M","L",""]) + + if asked.layout_subsections: + subsectioner = layouts['sections'][asked.layout_subsections](stacker, sort_on_priority_values, group_by_priority) + sectioner = layouts['sections'][asked.layout_sections](subsectioner, sort_on_status_values, group_by_status) + else: + sectioner = layouts['sections'][asked.layout_sections](stacker, sort_on_status_values, group_by_status) console = Console(theme = swatch) # console.rule("taskwarrior-deluxe")