ArgumentHelper | A library to parse command line arguments | Parser library
kandi X-RAY | ArgumentHelper Summary
kandi X-RAY | ArgumentHelper Summary
A library to parse command line arguments.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ArgumentHelper
ArgumentHelper Key Features
ArgumentHelper Examples and Code Snippets
Community Discussions
Trending Discussions on ArgumentHelper
QUESTION
I have a set of boolean argparse options: --foo/--no-foo
, --bar/--no-bar
, --baz/--no-baz
My script makes sense only if at least one of those options is set to True
.
I'd like to issue an Exception correctly processed by argparse
, which will be managed as a command line error clear message.
But argparse.ArgumentTypeError
is not a good option because it required the option as first argument to the constructor ... and my case is related to multiple options.
[Edit based on @00 comment:] The only solution I've got now is to raise, at the end of the command line processing, a ValueError is none of those options are set. But it is an exception, which is not user friendly.
What is the way to proceed in such cases?
Thanks a lot.
P.S.: Code to generate those options:
...ANSWER
Answered 2019-Jun-19 at 10:36According to Python argparse: Make at least one argument required:
Flexible argparse
errors can be created using parser.error("error message")
(see comments of @fabianegli in the question)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ArgumentHelper
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page