Last change
on this file since 25:8e33103a7e36 was 0:4cc6fc51063c, checked in by Borja Lopez <borja@…>, 10 years ago |
Initial commit, including basic structure of the project and initial features
|
|
File size:
873 bytes
|
Line | |
---|
1 | #!/usr/bin/env python
|
---|
2 |
|
---|
3 | import sys
|
---|
4 | from datetime import datetime
|
---|
5 | from stamper import DATE_FORMAT, Stamper
|
---|
6 |
|
---|
7 |
|
---|
8 | def usage(name):
|
---|
9 | msg = """
|
---|
10 | Usage:
|
---|
11 |
|
---|
12 | To start tracking time: %(name)s
|
---|
13 |
|
---|
14 | To record time for a given task: %(name)s customer action
|
---|
15 | """ % {'name': name}
|
---|
16 | print(msg)
|
---|
17 |
|
---|
18 |
|
---|
19 | if __name__ == '__main__':
|
---|
20 |
|
---|
21 | s = Stamper()
|
---|
22 | s.load_stamps()
|
---|
23 |
|
---|
24 | if len(sys.argv) == 1:
|
---|
25 | # stamp!
|
---|
26 | s.stamp(datetime.today().strftime(DATE_FORMAT), None, None, None)
|
---|
27 |
|
---|
28 | elif len(sys.argv) == 3:
|
---|
29 | # record!
|
---|
30 | last_stamp = s.last_stamp()
|
---|
31 | current_start = last_stamp['end']
|
---|
32 | if not current_start:
|
---|
33 | current_start = last_stamp['start']
|
---|
34 | s.stamp(current_start, datetime.today().strftime(DATE_FORMAT),
|
---|
35 | sys.argv[1], sys.argv[2])
|
---|
36 |
|
---|
37 | else:
|
---|
38 | usage(sys.argv[0])
|
---|
39 | sys.exit(1)
|
---|
40 |
|
---|
41 | s.save_stamps()
|
---|
Note:
See
TracBrowser
for help on using the repository browser.