diff --git a/covimerage/cli.py b/covimerage/cli.py index 7fb5b141..26f7ad0c 100644 --- a/covimerage/cli.py +++ b/covimerage/cli.py @@ -10,12 +10,14 @@ from .logger import logger from .utils import build_vim_profile_args, join_argv +context_settings = {'help_option_names': ['-h', '--help']} + def default_loglevel(): return logging.getLevelName(logger.level).lower() -@click.group(context_settings={'help_option_names': ['-h', '--help']}) +@click.group(context_settings=context_settings) @click.version_option(get_version(), '-V', '--version', prog_name='covimerage') @click.option('-v', '--verbose', count=True, help='Increase verbosity.') @click.option('-q', '--quiet', count=True, help='Decrease verbosity.') @@ -63,6 +65,7 @@ def write_coverage(profile_file, data_file, source, append): @main.command(context_settings=dict( + context_settings, # ignore_unknown_options=True, allow_interspersed_args=False, )) diff --git a/setup.py b/setup.py index 30997d7e..a7f0620c 100755 --- a/setup.py +++ b/setup.py @@ -73,7 +73,10 @@ def run(self): url='https://github.com/Vimjas/covimerage', packages=['covimerage'], entry_points={ - 'console_scripts': ['covimerage=covimerage.cli:main'], + 'console_scripts': [ + 'covimerage=covimerage.cli:main', + 'covimerage-run=covimerage.cli:run', + ], }, use_scm_version={ 'write_to': 'covimerage/__version__.py', diff --git a/tests/test_cli.py b/tests/test_cli.py index b39fe9e7..e81e4289 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -61,6 +61,12 @@ def test_cli_help(arg, runner): assert result.exit_code == 0 +def test_cli_run_shorthelp(runner): + result = runner.invoke(cli.run, ['-h']) + assert result.output.startswith('Usage:') + assert result.exit_code == 0 + + def test_cli_run_with_args_fd(capfd): ret = call(['covimerage', 'run', '--profile-file', '/doesnotexist', 'echo', '--', '--no-profile', '%sMARKER'])