I have a python command programe, it has optional --version and --help argument. I want to set them confict each other. it means i can not type --help --version at the same time.
When i type ./demo --version --help it outputs the program's version infomation. When i type ./demo --help --version it outputs the program's help infomation.
I think this is weird,so i want to set then confict each other.
I tried the add_mutually_exclusive_group, but it makes no sense.
My program likes below:
#!python3
# -*- coding: utf-8 -*-
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-v', '--version', action='version',
version='%(prog)s 1.0', help="Show program's version number and exit.")
#parser.parse_args(['--version','--help'])
parser.parse_args(['--help','--version'])
Thanks very much!
0 ·
Comments