Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions http_prompt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ def normalize_url(ctx, param, value):
@click.argument('http_options', nargs=-1, type=click.UNPROCESSED)
@click.version_option(message='%(version)s')
def cli(spec, env, url, http_options):
# Backward-compatible shortcut for issue #209:
# treat bare `-v` the same as `--version`.
if url == '-v' and not http_options and spec is None and env is None:
click.echo(__version__)
return

click.echo('Version: %s' % __version__)

copied, config_path = config.initialize()
Expand Down
6 changes: 6 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from requests.models import Response

from .base import TempAppDirTestCase
from http_prompt import __version__
from http_prompt import xdg
from http_prompt.context import Context
from http_prompt.cli import cli, execute, ExecutionListener
Expand Down Expand Up @@ -49,6 +50,11 @@ def run_and_exit(cli_args=None, prompt_commands=None):

class TestCli(TempAppDirTestCase):

def test_short_version_option(self):
result = CliRunner().invoke(cli, ['-v'])
self.assertEqual(result.exit_code, 0)
self.assertEqual(result.output.strip(), __version__)

def test_without_args(self):
result, context = run_and_exit(['http://localhost'])
self.assertEqual(result.exit_code, 0)
Expand Down