diff options
author | Adrián Oliva <adrian.oliva@cimat.mx> | 2023-05-08 19:22:43 -0600 |
---|---|---|
committer | Adrián Oliva <adrian.oliva@cimat.mx> | 2023-05-08 19:22:43 -0600 |
commit | 269eee248d24acbb12f13ab519dfbe1c881d3bb8 (patch) | |
tree | 5ca12e1c9d3aade19e45776763923bb2be1218aa | |
parent | 8aa967f32d8e7ca6da2d759bd49f0bb4ee2021b0 (diff) | |
download | Ledger.py-269eee248d24acbb12f13ab519dfbe1c881d3bb8.tar.gz Ledger.py-269eee248d24acbb12f13ab519dfbe1c881d3bb8.zip |
First step to adding filters to accounts.
Diffstat (limited to '')
-rwxr-xr-x | ledger.py | 6 | ||||
-rw-r--r-- | utils/args.py | 7 |
2 files changed, 7 insertions, 6 deletions
@@ -17,14 +17,14 @@ def main(): if args.sort: sort_entries(result, args.sort) - if args.verb == 'print': + if args.verb[0] == 'print': for ent in result: print(ent) - elif args.verb in ['register', 'reg', 'r']: + elif args.verb[0] in ['register', 'reg', 'r']: print_register(result) - elif args.verb in ['balance', 'bal', 'b']: + elif args.verb[0] in ['balance', 'bal', 'b']: print_balance(result) diff --git a/utils/args.py b/utils/args.py index e39d2fe..f479628 100644 --- a/utils/args.py +++ b/utils/args.py @@ -14,7 +14,8 @@ def get_arguments(): parser.add_argument('-v', '--version', action='version', version='%(prog)s 0.1') - parser.add_argument('verb', metavar='Action', action='store', + parser.add_argument('verb', metavar='Action', + action='store', nargs='+', help='Specify an action between balance, report and \ print.') parser.add_argument('-S', '--sort', metavar='value-expression', @@ -40,8 +41,8 @@ def test_args(my_args): 'register', 'reg', 'r', 'print' ] - if my_args.verb not in valid_verbs: - raise Exception(f'{my_args.verb} is NOT a valid verb! Valid verbs are: {", ".join(valid_verbs)}.') + if my_args.verb[0] not in valid_verbs: + raise Exception(f'{my_args.verb[0]} is NOT a valid verb! Valid verbs are: {", ".join(valid_verbs)}.') # Test if expression for sorting is valid. # TODO: How can we validate an expression??? |