Refactor command line argument parsing#19
Open
FMeinicke wants to merge 1 commit into
Open
Conversation
Parsing of command-line arguments is now done in a separate function which returns the parsed arguments. Additionally, most of the `add_argument` calls are now using the correct way to display help about what the argument is doing. Previously the `metavar` kwarg was used and not the `help` kwarg. I added some additional information where I thought the current help message was not enough (e.g. for the play_pause indicator it is really helpful to know that the argument expects a command separated string where 'play' comes first and 'pause' comes second.) Also, I added default values where possible to remove the kind of boilerplate code that checked if the command line argument is present and if so replaced a default value. This is now handled by argparse using the `default` kwarg.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When I did my last pull request I noticed some weird usage of argparse's `add_argument' kwargs.
Parsing of command-line arguments is now done in a separate function
which returns the parsed arguments. Additionally, most of the
add_argumentcalls are now using the correct way to display helpabout what the argument is doing. Previously the
metavarkwarg wasused and not the
helpkwarg. I added some additional informationwhere I thought the current help message was not enough (e.g. for the
play_pause indicator it is really helpful to know that the argument
expects a command separated string where 'play' comes first and 'pause'
comes second.) Also, I added default values where possible to remove
the kind of boilerplate code that checked if the command line
argument is present and if so replaced a default value. This is now
handled by argparse using the
defaultkwarg.