-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #475 from achilleas-k/nixio-subcommands
Command line: Top level nixio command with subcommands for command line scripts
- Loading branch information
Showing
5 changed files
with
113 additions
and
77 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
Command line interface for nixio tools. | ||
nixio explore: Print file information, data, or metadata, with support for | ||
filtering and plotting. | ||
nixio validate: Check NIX files for missing or inconsistent objects and | ||
annotations. | ||
nixio upgrade: Update older files to the newest file format. | ||
""" | ||
import argparse | ||
from . import explore, validate, upgrade | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description="Command line interface for nixio tools" | ||
) | ||
|
||
subcmds = parser.add_subparsers(title="commands", required=True, | ||
dest="cmd") | ||
|
||
# nixio explore | ||
explore_cmd = subcmds.add_parser("explore", help=explore.__doc__) | ||
explore.create_subcmd_parsers(explore_cmd) | ||
|
||
# nixio validate | ||
validate_cmd = subcmds.add_parser("validate", help=validate.__doc__) | ||
validate.create_subcmd_parser(validate_cmd) | ||
|
||
# nixio upgrade | ||
upgrade_cmd = subcmds.add_parser("upgrade", help=upgrade.__doc__) | ||
upgrade.create_subcmd_parser(upgrade_cmd) | ||
|
||
cmdmap = { | ||
"explore": explore.main, | ||
"validate": validate.main, | ||
"upgrade": upgrade.main | ||
} | ||
|
||
args = parser.parse_args() | ||
cmd = args.cmd | ||
cmdmap[cmd](args) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains 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
This file contains 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
This file contains 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