1 '''
2 Common argparse arguments for each script.
3 '''
4
5 import argparse
6
7 import fcp.node
8
10 '''
11 Argparse argument type for timeouts.
12 '''
13 try:
14 return fcp.node.parseTime(time_str)
15 except:
16 raise argparse.ArgumentTypeError("Invalid timeout: %s" % time_str)
17
19 '''
20 Add the default arguments to an argparse parser.
21 '''
22 parser.add_argument(
23 '--version',
24 '-V',
25 action='version',
26 version="%(prog)s " + fcp.node.fcpVersion,
27 )
28 parser.add_argument(
29 '--fcphost',
30 '-H',
31 default=fcp.node.defaultFCPHost,
32 help='''
33 Connect to FCP service at host <FCPHOST>.
34 (You may also use the environment variable FCP_HOST.)
35 ''',
36 )
37 parser.add_argument(
38 '--fcpport',
39 '-P',
40 default=fcp.node.defaultFCPPort,
41 type=int,
42 help='''
43 Connect to FCP service at port <FCPPORT>.
44 (You may also use the environment variable FCP_PORT.)
45 ''',
46 )
47 parser.add_argument(
48 '--timeout',
49 '-t',
50 default=fcp.node.ONE_YEAR,
51 type=timeout_type,
52 help='''
53 Set the timeout, in seconds, for completion.
54 Default one year.
55 ''',
56 )
57