Add the 'show' action for single tasks
This commit is contained in:
parent
bc623fc93f
commit
1bbbd799d1
@ -20,6 +20,17 @@ def rm(session: sa.orm.Session, index: int):
|
|||||||
session.commit()
|
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):
|
def ls(session: sa.orm.Session):
|
||||||
for i in session.query(Task).order_by(Task.created_at):
|
for i in session.query(Task).order_by(Task.created_at):
|
||||||
@ -41,6 +52,7 @@ if __name__ == '__main__':
|
|||||||
actions = {
|
actions = {
|
||||||
'add': add,
|
'add': add,
|
||||||
'rm': rm,
|
'rm': rm,
|
||||||
|
'show': show_by_id,
|
||||||
'ls': ls
|
'ls': ls
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +68,10 @@ if __name__ == '__main__':
|
|||||||
rm_parser.add_argument("index", type=int)
|
rm_parser.add_argument("index", type=int)
|
||||||
rm_parser.set_defaults(func=rm)
|
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 = subparsers.add_parser('ls')
|
||||||
ls_parser.set_defaults(func=ls)
|
ls_parser.set_defaults(func=ls)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user