aboutsummaryrefslogblamecommitdiff
path: root/ledger.py
blob: a418e6589cbc55bee80c94a50f43fa6889e65e3a (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11

                                               
                                       
                                         
                                   
                                       




                          
                  
                   
                               
                                       
 


                                       


                            
 


                                               


                                              


                          
#!/usr/bin/env python3
from utils.args import get_arguments, test_args
from utils.read_file import read_ledger
from utils.register import print_register
from utils.sort import sort_entries
from utils.balance import print_balance

def main():
    args = get_arguments()
    test_args(args)

    if args.files:
        result = []
        for file in args.files:
            result += read_ledger(file)

    if args.sort:
        sort_entries(result, args.sort)

    if args.verb == 'print':
        for ent in result:
            print(ent)

    elif args.verb in ['register', 'reg', 'r']:
        print_register(result)

    elif args.verb in ['balance', 'bal', 'b']:
        print_balance(result)


if __name__ == '__main__':
    main()