Skip to content

Commit a8ca741

Browse files
committed
Prefer dashes instead of underscores in flags
1 parent f4ece80 commit a8ca741

11 files changed

Lines changed: 74 additions & 30 deletions

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ def get_var(var_name):
3636
workflow-to-tools=ephemeris.generate_tool_list_from_ga_workflow_files:main
3737
setup-data-libraries=ephemeris.setup_data_libraries:main
3838
galaxy-wait=ephemeris.sleep:main
39+
install-tool-deps=ephemeris.install_tool_deps:main
3940
install_tool_deps=ephemeris.install_tool_deps:main
41+
set-library-permissions=ephemeris.set_library_permissions:main
4042
set_library_permissions=ephemeris.set_library_permissions:main
4143
'''
4244
PACKAGE_DATA = {

src/ephemeris/common_parser.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,28 @@
33
import argparse
44

55

6+
class HideUnderscoresHelpFormatter(argparse.HelpFormatter):
7+
def add_arguments(self, actions):
8+
for action in actions:
9+
action.option_strings = list(s for s in action.option_strings if "_" not in s)
10+
self.add_argument(action)
11+
12+
13+
class RawDescriptionHideUnderscoresHelpFormatter(HideUnderscoresHelpFormatter, argparse.RawDescriptionHelpFormatter):
14+
pass
15+
16+
17+
class ArgumentDefaultsHideUnderscoresHelpFormatter(HideUnderscoresHelpFormatter, argparse.ArgumentDefaultsHelpFormatter):
18+
pass
19+
20+
621
def get_common_args(login_required=True, log_file=False):
722

823
parser = argparse.ArgumentParser(add_help=False)
924
general_group = parser.add_argument_group('General options')
1025
general_group.add_argument("-v", "--verbose", help="Increase output verbosity.", action="store_true")
1126
if log_file:
12-
general_group.add_argument("--log_file",
27+
general_group.add_argument("--log-file", "--log_file",
1328
dest="log_file",
1429
help="Where the log file should be stored. "
1530
"Default is a file in your system's temp folder",
@@ -25,7 +40,7 @@ def get_common_args(login_required=True, log_file=False):
2540
help="Galaxy user email address")
2641
con_group.add_argument("-p", "--password",
2742
help="Password for the Galaxy user")
28-
con_group.add_argument("-a", "--api_key",
43+
con_group.add_argument("-a", "--api-key", "--api_key",
2944
dest="api_key",
3045
help="Galaxy admin user API key (required if not defined in the tools list file)")
3146

src/ephemeris/generate_tool_list_from_ga_workflow_files.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env python
22
'''Tool to generate tools from workflows'''
33
import json
4-
from argparse import ArgumentParser, RawDescriptionHelpFormatter
4+
from argparse import ArgumentParser
55

66
import yaml
77

8+
from .common_parser import RawDescriptionHideUnderscoresHelpFormatter
89
from .shed_tools_methods import format_tool_shed_url
910

1011
INSTALL_TOOL_DEPENDENCIES = 'install_tool_dependencies: True'
@@ -21,7 +22,7 @@ def _parse_cli_options():
2122

2223

2324
def _parser():
24-
parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter,
25+
parser = ArgumentParser(formatter_class=RawDescriptionHideUnderscoresHelpFormatter,
2526
usage="%(prog)s <options>",
2627
epilog="Workflow files must have been exported from Galaxy release 16.04 or newer.\n\n"
2728
"example:\n"
@@ -37,7 +38,7 @@ def _parser():
3738
required=True,
3839
dest='output_file',
3940
help='The output file with a yml tool list')
40-
parser.add_argument('-l', '--panel_label',
41+
parser.add_argument('-l', '--panel-label', '--panel_label',
4142
dest='panel_label',
4243
default='Tools from workflows',
4344
help='The name of the panel where the tools will show up in Galaxy.'

src/ephemeris/get_tool_list_from_galaxy.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python
22
"""Tool to extract a tool list from galaxy."""
33

4-
from argparse import ArgumentDefaultsHelpFormatter
54
from argparse import ArgumentParser
65
from distutils.version import StrictVersion
76

@@ -10,7 +9,7 @@
109
from bioblend.galaxy.toolshed import ToolShedClient
1110

1211
from . import get_galaxy_connection
13-
from .common_parser import get_common_args
12+
from .common_parser import ArgumentDefaultsHideUnderscoresHelpFormatter, get_common_args
1413
from .shed_tools_methods import format_tool_shed_url
1514

1615

@@ -216,29 +215,29 @@ def _parser():
216215
"""Creates the parser object."""
217216
parent = get_common_args(login_required=True)
218217
parser = ArgumentParser(parents=[parent],
219-
formatter_class=ArgumentDefaultsHelpFormatter)
218+
formatter_class=ArgumentDefaultsHideUnderscoresHelpFormatter)
220219
parser.add_argument("-o", "--output-file",
221220
required=True,
222221
dest="output",
223222
help="tool_list.yml output file")
224-
parser.add_argument("--include_tool_panel_id",
223+
parser.add_argument("--include-tool-panel-id", "--include_tool_panel_id",
225224
action="store_true",
226225
help="Include tool_panel_id in tool_list.yml ? "
227226
"Use this only if the tool panel id already exists. See "
228227
"https://github.com/galaxyproject/ansible-galaxy-tools/blob/master/files/tool_list.yaml.sample")
229-
parser.add_argument("--skip_tool_panel_name",
228+
parser.add_argument("--skip-tool-panel-name", "--skip_tool_panel_name",
230229
action="store_true",
231230
help="Do not include tool_panel_name in tool_list.yml ?")
232-
parser.add_argument("--skip_changeset_revision",
231+
parser.add_argument("--skip-changeset-revision", "--skip_changeset_revision",
233232
action="store_true",
234233
help="Do not include the changeset revision when generating the tool list."
235234
"Use this if you would like to use the list to update all the tools in"
236235
"your galaxy instance using shed-install."
237236
)
238-
parser.add_argument("--get_data_managers",
237+
parser.add_argument("--get-data-managers", "--get_data_managers",
239238
action="store_true",
240239
help="Include the data managers in the tool list. Requires admin login details")
241-
parser.add_argument("--get_all_tools",
240+
parser.add_argument("--get-all-tools", "--get_all_tools",
242241
action="store_true",
243242
help="Get all tools and revisions, not just those which are present on the web ui."
244243
"Requires login details.")

src/ephemeris/install_tool_deps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
from bioblend.galaxy.tools import ToolClient
1111

1212
from ephemeris import get_galaxy_connection
13-
from ephemeris.common_parser import get_common_args
13+
from ephemeris.common_parser import get_common_args, HideUnderscoresHelpFormatter
1414

1515
timeout_codes = (408, 502, 504)
1616

1717

1818
def _parser():
1919
parent = get_common_args()
20-
parser = argparse.ArgumentParser(parents=[parent])
20+
parser = argparse.ArgumentParser(parents=[parent], formatter_class=HideUnderscoresHelpFormatter)
2121
parser.add_argument("-t", "--tool", help='Path to a tool file, tool_conf file, or yaml file containing a sequence of tool ids', nargs='*')
2222
parser.add_argument("-i", "--id", help='Space-separated list of tool ids', nargs='*')
2323

src/ephemeris/run_data_managers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
from . import get_galaxy_connection
3737
from . import load_yaml_file
38-
from .common_parser import get_common_args
38+
from .common_parser import get_common_args, HideUnderscoresHelpFormatter
3939
from .ephemeris_log import disable_external_library_logging, setup_global_logger
4040

4141
DEFAULT_URL = "http://localhost"
@@ -288,13 +288,14 @@ def _parser():
288288

289289
parser = argparse.ArgumentParser(
290290
parents=[parent],
291+
formatter_class=HideUnderscoresHelpFormatter,
291292
description='Running Galaxy data managers in a defined order with defined parameters.'
292293
"'watch_tool_data_dir' in galaxy config should be set to true.'")
293294
parser.add_argument("--config", required=True,
294295
help="Path to the YAML config file with the list of data managers and data to install.")
295296
parser.add_argument("--overwrite", action="store_true",
296297
help="Disables checking whether the item already exists in the tool data table.")
297-
parser.add_argument("--ignore_errors", action="store_true",
298+
parser.add_argument("--ignore-errors", "--ignore_errors", action="store_true",
298299
help="Do not stop running when jobs have failed.")
299300
return parser
300301

src/ephemeris/set_library_permissions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from bioblend import galaxy
99
from rich.progress import Progress
1010

11-
from .common_parser import get_common_args
11+
from .common_parser import get_common_args, HideUnderscoresHelpFormatter
1212

1313
# Print iterations progress
1414

@@ -74,7 +74,9 @@ def _parser():
7474
"""Constructs the parser object"""
7575
parent = get_common_args()
7676
parser = argparse.ArgumentParser(
77-
parents=[parent], description="Populate the Galaxy data library with data."
77+
parents=[parent],
78+
formatter_class=HideUnderscoresHelpFormatter,
79+
description="Populate the Galaxy data library with data."
7880
)
7981
parser.add_argument("library", help="Specify the data library ID")
8082
parser.add_argument("--roles", nargs="+", help="Specify a list of comma separated role IDs")

src/ephemeris/setup_data_libraries.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import yaml
99
from bioblend import galaxy
1010

11-
from .common_parser import get_common_args
11+
from .common_parser import get_common_args, HideUnderscoresHelpFormatter
1212

1313

1414
def create_legacy(gi, desc):
@@ -189,6 +189,7 @@ def _parser():
189189
parent = get_common_args()
190190
parser = argparse.ArgumentParser(
191191
parents=[parent],
192+
formatter_class=HideUnderscoresHelpFormatter,
192193
description='Populate the Galaxy data library with data.'
193194
)
194195
parser.add_argument('-i', '--infile', required=True, type=argparse.FileType('r'))

0 commit comments

Comments
 (0)