source: stamper/bin/stamps@ 33:010949d4701d

Last change on this file since 33:010949d4701d was 32:80a51180155e, checked in by Borja Lopez <borja@…>, 10 years ago

Added support to delete up to N stamps from the list:

  • Delete the last recorded stamp:

stamp -d 1

  • Delete the last 10 stamps:

stamp -d 10

We ask for confirmation before proceeding with every stamp, in case
the user asks for the removal of multiple stamps, as soon as he does
not remove one of them, the following stamps could not be deleted.

  • Property exe set to *
File size: 1.6 KB
RevLine 
[0]1#!/usr/bin/env python
2
[10]3import argparse
[0]4from stamper import Stamper
5
6
7if __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')
[10]25
26 args = parser.parse_args()
27
[0]28 s = Stamper()
29 s.load_stamps()
[29]30
31 # Set proper arguments if they have passed a date-based filter without
32 # a customer
33 if args.customer not in s.customers and not args.filter:
34 args.filter = args.customer
35 args.customer = None
36
37 # Call the proper methods, based on the given parameters
[28]38 if args.timeline:
39 s.timeline()
[32]40 elif args.delete:
41 s.remove_stamps(args.delete)
[30]42 elif args.graph:
43 s.graph_stamps(args.customer, args.filter)
[28]44 else:
[30]45 s.show_stamps(args.customer, args.filter, args.verbose, args.sum)
Note: See TracBrowser for help on using the repository browser.