Skip to content

Commit f75834f

Browse files
committed
Prefer dashes instead of underscores in flags
1 parent fb5a294 commit f75834f

10 files changed

Lines changed: 99 additions & 24 deletions

src/ephemeris/common_parser.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
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
parser = argparse.ArgumentParser(add_help=False)
823
general_group = parser.add_argument_group("General options")
@@ -11,6 +26,7 @@ def get_common_args(login_required=True, log_file=False):
1126
)
1227
if log_file:
1328
general_group.add_argument(
29+
"--log-file",
1430
"--log_file",
1531
dest="log_file",
1632
help="Where the log file should be stored. "
@@ -31,6 +47,7 @@ def get_common_args(login_required=True, log_file=False):
3147
con_group.add_argument("-p", "--password", help="Password for the Galaxy user")
3248
con_group.add_argument(
3349
"-a",
50+
"--api-key",
3451
"--api_key",
3552
dest="api_key",
3653
help="Galaxy admin user API key (required if not defined in the tools list file)",

src/ephemeris/generate_tool_list_from_ga_workflow_files.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
#!/usr/bin/env python
22
"""Tool to generate tools from workflows"""
33
import json
4-
from argparse import (
5-
ArgumentParser,
6-
RawDescriptionHelpFormatter,
7-
)
4+
from argparse import ArgumentParser
85
from typing import (
96
Iterable,
107
List,
118
)
129

1310
import yaml
1411

12+
from .common_parser import RawDescriptionHideUnderscoresHelpFormatter
1513
from .shed_tools import InstallRepoDict
1614
from .shed_tools_methods import format_tool_shed_url
1715

@@ -30,7 +28,7 @@ def _parse_cli_options():
3028

3129
def _parser():
3230
parser = ArgumentParser(
33-
formatter_class=RawDescriptionHelpFormatter,
31+
formatter_class=RawDescriptionHideUnderscoresHelpFormatter,
3432
usage="%(prog)s <options>",
3533
epilog="Workflow files must have been exported from Galaxy release 16.04 or newer.\n\n"
3634
"example:\n"
@@ -55,6 +53,7 @@ def _parser():
5553
)
5654
parser.add_argument(
5755
"-l",
56+
"--panel-label",
5857
"--panel_label",
5958
dest="panel_label",
6059
default="Tools from workflows",

src/ephemeris/get_tool_list_from_galaxy.py

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

4-
from argparse import (
5-
ArgumentDefaultsHelpFormatter,
6-
ArgumentParser,
7-
)
4+
from argparse import ArgumentParser
85
from distutils.version import StrictVersion
96

107
import yaml
118
from bioblend.galaxy.tools import ToolClient
129
from bioblend.galaxy.toolshed import ToolShedClient
1310

1411
from . import get_galaxy_connection
15-
from .common_parser import get_common_args
12+
from .common_parser import (
13+
ArgumentDefaultsHideUnderscoresHelpFormatter,
14+
get_common_args,
15+
)
1616
from .shed_tools_methods import format_tool_shed_url
1717

1818

@@ -245,7 +245,7 @@ def _parser():
245245
"""Creates the parser object."""
246246
parent = get_common_args(login_required=True)
247247
parser = ArgumentParser(
248-
parents=[parent], formatter_class=ArgumentDefaultsHelpFormatter
248+
parents=[parent], formatter_class=ArgumentDefaultsHideUnderscoresHelpFormatter
249249
)
250250
parser.add_argument(
251251
"-o",
@@ -255,30 +255,35 @@ def _parser():
255255
help="tool_list.yml output file",
256256
)
257257
parser.add_argument(
258+
"--include-tool-panel-id",
258259
"--include_tool_panel_id",
259260
action="store_true",
260261
help="Include tool_panel_id in tool_list.yml ? "
261262
"Use this only if the tool panel id already exists. See "
262263
"https://github.com/galaxyproject/ansible-galaxy-tools/blob/master/files/tool_list.yaml.sample",
263264
)
264265
parser.add_argument(
266+
"--skip-tool-panel-name",
265267
"--skip_tool_panel_name",
266268
action="store_true",
267269
help="Do not include tool_panel_name in tool_list.yml ?",
268270
)
269271
parser.add_argument(
272+
"--skip-changeset-revision",
270273
"--skip_changeset_revision",
271274
action="store_true",
272275
help="Do not include the changeset revision when generating the tool list."
273276
"Use this if you would like to use the list to update all the tools in"
274277
"your galaxy instance using shed-install.",
275278
)
276279
parser.add_argument(
280+
"--get-data-managers",
277281
"--get_data_managers",
278282
action="store_true",
279283
help="Include the data managers in the tool list. Requires admin login details",
280284
)
281285
parser.add_argument(
286+
"--get-all-tools",
282287
"--get_all_tools",
283288
action="store_true",
284289
help="Get all tools and revisions, not just those which are present on the web ui."

src/ephemeris/install_tool_deps.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@
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 (
14+
get_common_args,
15+
HideUnderscoresHelpFormatter,
16+
)
1417

1518
timeout_codes = (408, 502, 504)
1619

1720

1821
def _parser():
1922
parent = get_common_args()
20-
parser = argparse.ArgumentParser(parents=[parent])
23+
parser = argparse.ArgumentParser(parents=[parent], formatter_class=HideUnderscoresHelpFormatter)
2124
parser.add_argument(
2225
"-t",
2326
"--tool",

src/ephemeris/run_data_managers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@
3737
get_galaxy_connection,
3838
load_yaml_file,
3939
)
40-
from .common_parser import get_common_args
40+
from .common_parser import (
41+
get_common_args,
42+
HideUnderscoresHelpFormatter,
43+
)
4144
from .ephemeris_log import (
4245
disable_external_library_logging,
4346
setup_global_logger,
@@ -320,6 +323,7 @@ def _parser():
320323

321324
parser = argparse.ArgumentParser(
322325
parents=[parent],
326+
formatter_class=HideUnderscoresHelpFormatter,
323327
description="Running Galaxy data managers in a defined order with defined parameters."
324328
"'watch_tool_data_dir' in galaxy config should be set to true.'",
325329
)
@@ -334,6 +338,7 @@ def _parser():
334338
help="Disables checking whether the item already exists in the tool data table.",
335339
)
336340
parser.add_argument(
341+
"--ignore-errors",
337342
"--ignore_errors",
338343
action="store_true",
339344
help="Do not stop running when jobs have failed.",

src/ephemeris/set_library_permissions.py

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

12-
from .common_parser import get_common_args
12+
from .common_parser import (
13+
get_common_args,
14+
HideUnderscoresHelpFormatter,
15+
)
1316

1417
# Print iterations progress
1518

@@ -75,7 +78,9 @@ def _parser():
7578
"""Constructs the parser object"""
7679
parent = get_common_args()
7780
parser = argparse.ArgumentParser(
78-
parents=[parent], description="Populate the Galaxy data library with data."
81+
parents=[parent],
82+
formatter_class=HideUnderscoresHelpFormatter,
83+
description="Populate the Galaxy data library with data."
7984
)
8085
parser.add_argument("library", help="Specify the data library ID")
8186
parser.add_argument(

src/ephemeris/setup_data_libraries.py

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

11-
from .common_parser import get_common_args
11+
from .common_parser import (
12+
get_common_args,
13+
HideUnderscoresHelpFormatter,
14+
)
1215

1316

1417
def create_legacy(gi, desc):
@@ -211,7 +214,9 @@ def _parser():
211214
"""Constructs the parser object"""
212215
parent = get_common_args()
213216
parser = argparse.ArgumentParser(
214-
parents=[parent], description="Populate the Galaxy data library with data."
217+
parents=[parent],
218+
formatter_class=HideUnderscoresHelpFormatter,
219+
description="Populate the Galaxy data library with data."
215220
)
216221
parser.add_argument("-i", "--infile", required=True, type=argparse.FileType("r"))
217222
parser.add_argument(

0 commit comments

Comments
 (0)