Filter 'ls' results by 'active' by default
This commit is contained in:
parent
9a18e8a940
commit
0f55007a60
@ -42,8 +42,12 @@ def show_by_id(session: sa.orm.Session, index: int):
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
def ls(session: sa.orm.Session):
|
||||
for i in session.query(Task).order_by(Task.created_at):
|
||||
def ls(session: sa.orm.Session, _all: False):
|
||||
vals = session.query(Task).order_by(Task.created_at)
|
||||
if _all is False:
|
||||
vals = vals.filter(Task.active is True)
|
||||
|
||||
for i in vals:
|
||||
show_by_obj(session, i)
|
||||
|
||||
|
||||
@ -88,7 +92,8 @@ if __name__ == '__main__':
|
||||
show_parser.add_argument('index', type=int)
|
||||
|
||||
ls_parser = subparsers.add_parser('ls')
|
||||
ls_parser.set_defaults(func=ls)
|
||||
ls_parser.set_defaults(func=ls, _all=False)
|
||||
ls_parser.add_argument('--all', dest='_all', action='store_const', const='true', help="Show inactive tasks")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user