@@ -11,7 +11,7 @@ def generate_data(n, a=0, b=1):
11
11
return [random .randint (a , b ) for _ in range (n )]
12
12
13
13
def main ():
14
- arg_parser = ArgumentParser (description = 'test application' )
14
+ arg_parser = ArgumentParser (add_help = False )
15
15
arg_parser .add_argument ('--conf' ,
16
16
help = 'configuration file to use' )
17
17
arg_parser .add_argument ('--verbose' , action = 'store_true' ,
@@ -36,12 +36,14 @@ def main():
36
36
print ('user configuration file values:' , file = sys .stderr )
37
37
cfg .write (sys .stderr )
38
38
cfg_opts = dict (cfg ['defaults' ])
39
- arg_parser .set_defaults (** cfg_opts )
40
- arg_parser .add_argument ('n' , type = int , nargs = '?' ,
41
- help = 'number of random values to generate' )
42
- arg_parser .add_argument ('--a' , type = int , help = 'smallest value' )
43
- arg_parser .add_argument ('--b' , type = int , help = 'largest value' )
44
- arg_parser .parse_args (remaining_options , options )
39
+ arg_parser_cl = ArgumentParser (description = 'test application' ,
40
+ parents = [arg_parser ])
41
+ arg_parser_cl .set_defaults (** cfg_opts )
42
+ arg_parser_cl .add_argument ('n' , type = int , nargs = '?' ,
43
+ help = 'number of random values to generate' )
44
+ arg_parser_cl .add_argument ('--a' , type = int , help = 'smallest value' )
45
+ arg_parser_cl .add_argument ('--b' , type = int , help = 'largest value' )
46
+ arg_parser_cl .parse_args (remaining_options , options )
45
47
if options .verbose :
46
48
print ('final options:' , file = sys .stderr )
47
49
print (f'n = { options .n } \n a = { options .a } \n b = { options .b } ' , end = '\n \n ' ,
0 commit comments