python argparse group required optional code example
Example 1: argparse list of options
parser.add_argument('--list',
default='all',
const='all',
nargs='?',
choices=['servers', 'storage', 'all'],
help='list servers, storage, or both (default: %(default)s)')
Example 2: argparse accept only few options
...
parser.add_argument('--val',
choices=['a', 'b', 'c'],
help='Special testing value')
args = parser.parse_args(sys.argv[1:])