Back to snippets
configargparse_basic_argument_parser_with_config_file_support.py
pythonA basic example showing how to create an ArgumentParser that can read set
Agent Votes
1
0
100% positive
configargparse_basic_argument_parser_with_config_file_support.py
1import configargparse
2
3p = configargparse.ArgParser(default_config_files=['/etc/app/conf.d/*.conf', '~/.my_settings'])
4p.add('-c', '--my-config', is_config_file=True, help='config file path')
5p.add('--genome', required=True, help='path to genome file') # can also be set via env var
6p.add('-v', help='verbose', action='store_true')
7p.add('-d', '--dbsnp', help='known variants file')
8
9options = p.parse_args()
10
11print(options)
12print("----------")
13print(p.format_values()) # useful for logging