Skip to content

Commit

Permalink
Add --dash-syntax as alias to all CLI args
Browse files Browse the repository at this point in the history
Previously all args were in the form --argument_one. This allows the dash to be used in place of an underscore. This has no effect on what will be printed into the config file, as all dashes (-) are converted to underscores (_) internally.

Resolves khanlab#10
  • Loading branch information
pvandyken committed Dec 6, 2021
1 parent 1249967 commit d40ea87
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions snakebids/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def _create_parser(self, include_snakemake=False):

parser.add_argument(
"--workflow-mode",
"--workflow_mode",
"-W",
action="store_true",
help=(
Expand All @@ -268,6 +269,7 @@ def _create_parser(self, include_snakemake=False):
# We use -x as the alias because both -f and -F are taken by snakemake
parser.add_argument(
"--force-conversion",
"--force_conversion",
"-x",
action="store_true",
help=(
Expand All @@ -288,6 +290,7 @@ def _create_parser(self, include_snakemake=False):

# add option for printing out snakemake usage
parser.add_argument(
"--help-snakemake",
"--help_snakemake",
nargs=0,
action=SnakemakeHelpAction,
Expand Down Expand Up @@ -326,7 +329,7 @@ def _create_parser(self, include_snakemake=False):
)

for input_type in self.config["pybids_inputs"].keys():
argname = f"--filter_{input_type}"
argnames = (f"--filter_{input_type}", f"--filter-{input_type}")
arglist_default = [
f"{key}={value}"
for (key, value) in self.config["pybids_inputs"][input_type][
Expand All @@ -336,7 +339,7 @@ def _create_parser(self, include_snakemake=False):
arglist_default_string = " ".join(arglist_default)

filter_opts.add_argument(
argname,
*argnames,
nargs="+",
action=KeyValue,
help=f"(default: {arglist_default_string})",
Expand All @@ -351,14 +354,14 @@ def _create_parser(self, include_snakemake=False):
)

for input_type in self.config["pybids_inputs"].keys():
argname = f"--wildcards_{input_type}"
argnames = (f"--wildcards-{input_type}", f"--wildcards_{input_type}")
arglist_default = [
f"{wc}" for wc in self.config["pybids_inputs"][input_type]["wildcards"]
]
arglist_default_string = " ".join(arglist_default)

wildcards_opts.add_argument(
argname,
*argnames,
nargs="+",
help=f"(default: {arglist_default_string})",
)
Expand All @@ -374,8 +377,8 @@ def _create_parser(self, include_snakemake=False):

# create path override parser
for input_type in self.config["pybids_inputs"].keys():
argname = f"--path_{input_type}"
override_opts.add_argument(argname, default=None)
argnames = (f"--path-{input_type}", f"--path_{input_type}")
override_opts.add_argument(*argnames, default=None)

return parser

Expand Down

0 comments on commit d40ea87

Please sign in to comment.