source: stamper/bin/stamps@ 38:fb741bfe9e1d

Last change on this file since 38:fb741bfe9e1d was 38:fb741bfe9e1d, checked in by Borja Lopez <borja@…>, 10 years ago

The timeline feature accepts now date-based filters:

  • Show the timeline for the last week:

stamps -t 1w

  • Show the timeline for august, 2013:

stamps -t 2013-08-01--2013-09-01

And so on.

  • Property exe set to *
File size: 1.9 KB
Line 
1#!/usr/bin/env python
2
3import argparse
4from stamper import Stamper
5
6
7if __name__ == '__main__':
8
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')
17 parser.add_argument('-s', '--sum', action="store_true",
18 help='Include sum of times')
19 parser.add_argument('-g', '--graph', action="store_true",
20 help='Generate a SVG graph')
21 parser.add_argument('-t', '--timeline', action="store_true",
22 help='Show a timeline of recorded times')
23 parser.add_argument('-d', '--delete', action="store", type=int,
24 help='Delete up to n recorded stamps')
25 parser.add_argument('-i', '--import', action="store", dest="import_file",
26 help='Import stamps from the given file')
27
28 args = parser.parse_args()
29
30 s = Stamper()
31 s.load_stamps()
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
40 if args.timeline:
41 s.timeline(args.filter)
42 elif args.delete:
43 s.remove_stamps(args.delete)
44 elif args.graph:
45 s.graph_stamps(args.customer, args.filter)
46 elif args.import_file:
47 s.import_stamps(args.import_file)
48 else:
49 s.show_stamps(args.customer, args.filter, args.verbose, args.sum)
Note: See TracBrowser for help on using the repository browser.