piknik

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

commit 3cd29258719cc43745cc9d3a9d00699c0969207f
parent a57207f3237a248097200d72a2f3ad73ce04554e
Author: lash <dev@holbrook.no>
Date:   Mon,  7 Nov 2022 19:01:55 +0000

Add show command

Diffstat:
Mpiknik/basket.py | 2++
Apiknik/runnable/show.py | 38++++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/piknik/basket.py b/piknik/basket.py @@ -127,4 +127,6 @@ class Basket: def tags(self, issue_id): v = self.__tags.state(issue_id) r = self.__tags.elements(v) + if r == 'UNTAGGED': + r = '(' + r + ')' return shep.state.split_elements(r) diff --git a/piknik/runnable/show.py b/piknik/runnable/show.py @@ -0,0 +1,38 @@ +import sys +import argparse + +from piknik import Basket +from piknik import Issue +from piknik.store import FileStoreFactory + + +argp = argparse.ArgumentParser() +argp.add_argument('-d', type=str, help='Data directory') +argp.add_argument('-r', '--renderer', type=str, default='default', help='Renderer module for output') +argp.add_argument('issue_id', type=str, help='Issue id to show') +arg = argp.parse_args(sys.argv[1:]) + +store_factory = FileStoreFactory(arg.d) +basket = Basket(store_factory) + + +def render_default(b, o, t): + print("""id: {} +title: {} +tags: {} + """.format( + o.id, + o.title, + ', '.join(t), + ) + ) + +def main(): + o = basket.get(arg.issue_id) + t = basket.tags(arg.issue_id) + + globals()['render_' + arg.renderer](basket, o, t) + + +if __name__ == '__main__': + main()