diff --git a/src/pyelephant.py b/src/pyelephant.py index 7670038..86990d4 100755 --- a/src/pyelephant.py +++ b/src/pyelephant.py @@ -20,6 +20,17 @@ def rm(session: sa.orm.Session, index: int): session.commit() +# ----------------------------------------------------------------------------- +def show_by_obj(session: sa.orm.Session, obj: Task): + print(obj.id, obj.created_at, obj.active, obj.title) + + +# ----------------------------------------------------------------------------- +def show_by_id(session: sa.orm.Session, index: int): + obj = session.query(Task.id == index) + show_by_obj(obj) + + # ----------------------------------------------------------------------------- def ls(session: sa.orm.Session): for i in session.query(Task).order_by(Task.created_at): @@ -41,6 +52,7 @@ if __name__ == '__main__': actions = { 'add': add, 'rm': rm, + 'show': show_by_id, 'ls': ls } @@ -56,6 +68,10 @@ if __name__ == '__main__': rm_parser.add_argument("index", type=int) rm_parser.set_defaults(func=rm) + show_parser = subparsers.add_parser('show') + show_parser.add_argument('indx', type=int) + show_parser.set_defaults(func=show_by_id) + ls_parser = subparsers.add_parser('ls') ls_parser.set_defaults(func=ls)