-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.py
More file actions
29 lines (22 loc) · 1.05 KB
/
parser.py
File metadata and controls
29 lines (22 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import sys
import argparse
class MyParser(argparse.ArgumentParser):
description = 'Process script parameters.'
def error(self, message):
sys.stderr.write('error: %s\n' % message)
self.print_help()
sys.exit(2)
def parse(args):
parser = MyParser()
type_group = parser.add_mutually_exclusive_group(required=True)
type_group.add_argument('-c', '--commits', default=False, action='store_true',
help='use sha1 identifier')
type_group.add_argument('-d', '--dates', default=False, action='store_true',
help='use dates')
type_group.add_argument('-t', '--timestamps', default=False, action='store_true',
help='use timestamps')
parser.add_argument('bad_commit', help='define the sha1 or date of the bad commit')
parser.add_argument('good_commit', help='define the sha1 or date of the good commit')
parser.add_argument('-s', '--script', help='define the shell script to run as benchmark')
args = parser.parse_args(args)
return args