[0] | 1 | #!/usr/bin/env python
|
---|
| 2 |
|
---|
[10] | 3 | import argparse
|
---|
[0] | 4 | from stamper import Stamper
|
---|
| 5 |
|
---|
| 6 |
|
---|
| 7 | if __name__ == '__main__':
|
---|
| 8 |
|
---|
[10] | 9 | parser = argparse.ArgumentParser(
|
---|
| 10 | description='stamps: show recorded times information')
|
---|
| 11 | parser.add_argument('customer', action="store", nargs='?',
|
---|
| 12 | help='Show times only for this customer')
|
---|
| 13 | parser.add_argument('filter', action="store", nargs='?',
|
---|
| 14 | help='Filter the times by date range')
|
---|
| 15 | parser.add_argument('-v', '--verbose', action="store_true",
|
---|
| 16 | help='Include detailed times information')
|
---|
[22] | 17 | parser.add_argument('-s', '--sum', action="store_true",
|
---|
| 18 | help='Include sum of times')
|
---|
[23] | 19 | parser.add_argument('-g', '--graph', action="store_true",
|
---|
| 20 | help='Generate a SVG graph')
|
---|
[28] | 21 | parser.add_argument('-t', '--timeline', action="store_true",
|
---|
| 22 | help='Show a timeline of recorded times')
|
---|
[32] | 23 | parser.add_argument('-d', '--delete', action="store", type=int,
|
---|
| 24 | help='Delete up to n recorded stamps')
|
---|
[37] | 25 | parser.add_argument('-i', '--import', action="store", dest="import_file",
|
---|
| 26 | help='Import stamps from the given file')
|
---|
[10] | 27 |
|
---|
| 28 | args = parser.parse_args()
|
---|
| 29 |
|
---|
[0] | 30 | s = Stamper()
|
---|
| 31 | s.load_stamps()
|
---|
[29] | 32 |
|
---|
| 33 | # Set proper arguments if they have passed a date-based filter without
|
---|
| 34 | # a customer
|
---|
| 35 | if args.customer not in s.customers and not args.filter:
|
---|
| 36 | args.filter = args.customer
|
---|
| 37 | args.customer = None
|
---|
| 38 |
|
---|
| 39 | # Call the proper methods, based on the given parameters
|
---|
[28] | 40 | if args.timeline:
|
---|
[38] | 41 | s.timeline(args.filter)
|
---|
[32] | 42 | elif args.delete:
|
---|
| 43 | s.remove_stamps(args.delete)
|
---|
[30] | 44 | elif args.graph:
|
---|
| 45 | s.graph_stamps(args.customer, args.filter)
|
---|
[37] | 46 | elif args.import_file:
|
---|
| 47 | s.import_stamps(args.import_file)
|
---|
[28] | 48 | else:
|
---|
[30] | 49 | s.show_stamps(args.customer, args.filter, args.verbose, args.sum)
|
---|