Skip to content

Commit 23c6b2c

Browse files
authored
CLI shows help without args (broadinstitute#100)
* Lint. * Add vscode configs to the ignore file. * Update build badges. * Show help when no arguments provided. * Make it work.
1 parent 6c7396f commit 23c6b2c

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ __pycache__/
55
docker/cromwell-metadata/cromwell_credentials.txt
66
docker/cromwell-metadata/caas_key.json
77

8+
# IDE
9+
.vscode/
10+
811
# Sphinx documentation
912
docs/_build/
1013

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Cromwell-tools
55
:target: https://quay.io/repository/broadinstitute/cromwell-tools
66
:alt: Container Build Status
77

8-
.. image:: https://github.com/broadinstitute/cromwell-tools/workflows/Tests%20on%20Pull%20Requests%20and%20Master/badge.svg?branch=master
9-
:target: https://github.com/broadinstitute/cromwell-tools/actions?query=workflow%3A%22Tests+on+Pull+Requests+and+Master%22+branch%3Arex-switch-to-GithubActions
8+
.. image:: https://github.com/broadinstitute/cromwell-tools/workflows/Tests%20on%20Pull%20Requests%20and%20Master/badge.svg
9+
:target: https://github.com/broadinstitute/cromwell-tools/actions?query=workflow%3A%22Tests+on+Pull+Requests+and+Master%22+branch%3Amaster
1010
:alt: Unit Test Status
1111

1212
.. image:: https://img.shields.io/readthedocs/cromwell-tools/latest.svg?label=ReadtheDocs%3A%20Latest&logo=Read%20the%20Docs&style=flat-square

cromwell_tools/cli.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,23 @@
44
from cromwell_tools.cromwell_auth import CromwellAuth
55
from cromwell_tools.diag import task_runtime
66
from cromwell_tools import __version__
7+
import sys
78

89

910
diagnostic_index = {'task_runtime': task_runtime.run}
1011

1112

13+
class DefaultHelpParser(argparse.ArgumentParser):
14+
def error(self, message):
15+
sys.stderr.write('error: %s\n' % message)
16+
self.print_help()
17+
sys.exit(2)
18+
19+
1220
def parser(arguments=None):
1321
# TODO: dynamically walk through the commands and automatcally create parsers here
1422

15-
main_parser = argparse.ArgumentParser()
23+
main_parser = DefaultHelpParser()
1624

1725
# Check the installed version of Cromwell-tools
1826
main_parser.add_argument(
@@ -249,6 +257,10 @@ def add_auth_args(subcommand_parser):
249257
# group all of the arguments
250258
args = vars(main_parser.parse_args(arguments))
251259

260+
# Return help messages if no arguments provided
261+
if not args['command']:
262+
main_parser.error("No commands/arguments provided!")
263+
252264
# TODO: see if this can be moved or if the commands can be populated from above
253265
if args['command'] in (
254266
'submit',

cromwell_tools/cromwell_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,5 +613,5 @@ def _check_and_raise_status(response: requests.Response) -> None:
613613
if not response.ok:
614614
raise requests.exceptions.HTTPError(
615615
'Error Code {0}: {1}'.format(response.status_code, response.text),
616-
response=response
616+
response=response,
617617
)

0 commit comments

Comments
 (0)