Skip to content

Commit

Permalink
Add covimerage-run console script
Browse files Browse the repository at this point in the history
This is required/useful for when a single command is required to wrap
Vim, e.g. with vim-thesis.
  • Loading branch information
blueyed committed Oct 23, 2018
1 parent bb84cc9 commit 75300f1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion covimerage/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand Down Expand Up @@ -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,
))
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down

0 comments on commit 75300f1

Please sign in to comment.