![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
configurable-argparse-DavidRodriguezSoaresCUI
Advanced tools
Argparse-based way of CLI argument handling boosted by YAML reusable configurations
When writing a command-line Python script that needs to take many arguments, usability issues may arise:
Configurable argparse aims at offloading the "noise" (often used argument configurations) into "recipes" that can be reused, while retaining the ability to override what needs to be adapted (the "signal"), therefore giving the user an experience that allows to efficiently use the program.
This simple example is there show how to use configurable argparse and how it makes using
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument(
'-t', '--nb_threads',
type: int, default=4,
help="Number of threads to use"
)
...
exclusive_group = parser.add_mutually_exclusive_group()
exclusive_group.add_argument(
'--verbose',
action='store_true',
help='Show all messages'
)
exclusive_group.add_argument(
'--quiet',
action='store_true',
help='Show no messages'
)
parser.parse_args()
...
def main():
args = get_args()
Usage example:
python example_program.py -t 4 --use_library=libabc --ignore=E123,E321 --add_src=/homes/user/documents/ --quality=0.65 --no_audio --quiet
In this example, if the user wants to change an argument from run to run, the difference is lost in the "noise".
ARGPARSE_PARSER_ARGS = {"prog": "Example program"}
ARGPARSE_ARGUMENTS = [
Argument(
('-t', '--nb_threads'),
{
'type': int,
'default': 4,
'help': "Number of threads to use"
}
),
...
ArgumentExclusiveGroup([
Argument(
'--verbose',
{
'action': 'store_true',
'help': 'Show all messages'
}
),
Argument(
'--quiet',
{
'action': 'store_true',
'help': 'Show no messages'
}
)
])
]
...
def main():
args = get_args(
parser_args=ARGPARSE_PARSER_ARGS,
arguments=ARGPARSE_ARGUMENTS,
yaml_config_base=Path(__file__)
)
Usage example:
python example_program.py -t 4 --use_library=libabc --ignore=E123,E321 --add_src=/homes/user/documents/ --quality=0.65 --no_audio --quiet
(save config as usual
)python example_program.py --use_config=usual --quality=0.55
In this example, if the user wants to change an argument from run to run, the difference is immediately apparent since the "noise" is abstracted away in a usual
configuration.
FAQs
Argparse-based way of CLI argument handling boosted by YAML reusable configurations
We found that configurable-argparse-DavidRodriguezSoaresCUI demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.