Closed ilejn closed 2 months ago
My bad, the attempt to have two parameters with same dest
IS successful.
I have
parser.add_argument(
"--silent",
action="store_true",
dest="silent_flag",
default=False,
help="no log"
)
parser.add_argument(
"--silentflag",
"--silent-flag",
dest="silent_flag",
type=bool,
default=False,
help="no log"
)
Hello, I have simple command line flags, that perfectly work with action="store_true". I would like to have it controlled via environment as well, but it does not work well.
Ideally I want to specify
myscript --debug
orDEBUG=true myscript
and it works indeed, unless I tryDEBUG=false myscript
. The latest one is converted to True as well.The question is what is the best way to achieve the goal.
Switching to
type=bool
works, but not convenient as for commandline. Attempt to have two parameters with samedest
is not successful (obviously).