Add the 'done' command
This commit is contained in:
parent
16224076ec
commit
9a18e8a940
@ -16,6 +16,14 @@ def add(session: sa.orm.Session, title: str):
|
||||
show_by_obj(obj)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
def done(session: sa.orm.Session, index: int):
|
||||
obj = session.query(Task).filter(Task.id == index).one()
|
||||
assert(obj.active is True)
|
||||
obj.active = False
|
||||
session.commit()
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
def rm(session: sa.orm.Session, index: int):
|
||||
session.query(Task).filter(Task.id == index).delete()
|
||||
@ -53,6 +61,7 @@ if __name__ == '__main__':
|
||||
|
||||
actions = {
|
||||
'add': add,
|
||||
'done': done,
|
||||
'rm': rm,
|
||||
'show': show_by_id,
|
||||
'ls': ls
|
||||
@ -66,6 +75,10 @@ if __name__ == '__main__':
|
||||
add_parser.set_defaults(func=add)
|
||||
add_parser.add_argument("title", type=str)
|
||||
|
||||
done_parser = subparsers.add_parser('done')
|
||||
done_parser.set_defaults(func=done)
|
||||
done_parser.add_argument('index', type=int)
|
||||
|
||||
rm_parser = subparsers.add_parser('rm')
|
||||
rm_parser.set_defaults(func=rm)
|
||||
rm_parser.add_argument("index", type=int)
|
||||
|
Loading…
Reference in New Issue
Block a user