-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Command line: Top level nixio command with subcommands for command line scripts #475
Conversation
Adds subcmds for all the previous command line tools: explore, validate, and upgrade. The help text of each of the subcommands is stored in the __doc__ string at the top of the file.
Each subcommand implements a create_subcmd_parsers() function that receives the parent parser and adds its own parsing subcommands and options. The main() function of each subcommand receives the top level parsed 'args' object and uses it as it did previously. Old subcommand main() flow: 1. Define parser 2. Define subparsers 3. Parse args 4. Use args to call functions and pass args. New top-level command main() flow: 1. Define top level parser 2. Define subcommand names 3. Pass subcommand parser to each subcommand 'create_subcommand_parsers()' 3.1 Each subcommand defines its subparser 4. Parse args 5. Use args to call subcommand and pass args to subcommand main() 5.1 Subcommand main() uses args to call appropriate function and validate options.
This pull request introduces 3 alerts when merging ac2bf0d into cc207ce - view on LGTM.com new alerts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! Found a few tiny things and if you don't mind fixing a typo in line 591 in explore.py for me ("by default")
nixio/cmd/explore.py
Outdated
a property with matching name. 2) type_or_name/prop_name: first looks for a | ||
matching section and within those for matching properties. Patterns are | ||
applied case-insensitive and can be partial matches. You can provide multiple | ||
patterns by calling the command like: `nixio-explore metadata -p "subject" -p |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this should now be ... like: 'nixio explore metadata -p ... '
nixio/cmd/explore.py
Outdated
dimension information as well as the stored data. To write the data to text file use e.g. | ||
\'nixio-explore dump path_to_nix_file -p \"name or type of data entity\" > data.dump\' or provide the \"--outfile\" argument. | ||
""".strip() | ||
Dump data to stdout. This command can process up to 3D data. The data dump |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe change to: "Dump data to file or stdout. "
nixio/cmd/explore.py
Outdated
""".strip() | ||
Dump data to stdout. This command can process up to 3D data. The data dump | ||
contains dimension information as well as the stored data. To write the data | ||
to text file use e.g. 'nixio-explore dump path_to_nix_file -p "name or type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the example command should now be: nixio explore dump ...
Typos and mentions of old 'nixio-explore' command.
Thanks for catching these. Fixed. |
Package defines a single command line interface
nixio
which calls the appropriate script innixio/cmd/
based on subcommand.Each subcommand implements a
create_subcmd_parsers()
function that receives the parent parser and adds its own parsing subcommands and options.The
main()
function of each subcommand receives the top level parsed 'args' object and uses it as it did previously.Old
subcommand main()
flow:New top-level command
main()
flow:create_subcommand_parsers()
3.1 Each subcommand defines its subparser
main()
5.1 Subcommand
main()
uses args to call appropriate function and validate options.Here's the output of the `--help` for level for easier review and clarity (note that line length is terminal width dependent and is adjusted automatically by argparse):