--- http_prompt/cli.py.orig 2019-03-11 10:35:47.000000000 -0400 +++ http_prompt/cli.py 2019-03-11 10:36:10.000000000 -0400 @@ -9,11 +9,11 @@ from httpie.plugins import FormatterPlugin # noqa, avoid cyclic import from httpie.output.formatters.colors import Solarized256Style -from prompt_toolkit import prompt, AbortAction +from prompt_toolkit import prompt from prompt_toolkit.auto_suggest import AutoSuggestFromHistory from prompt_toolkit.history import FileHistory -from prompt_toolkit.layout.lexers import PygmentsLexer -from prompt_toolkit.styles.from_pygments import style_from_pygments +from prompt_toolkit.lexers import PygmentsLexer +from prompt_toolkit.styles.pygments import style_from_pygments_cls from pygments.styles import get_style_by_name from pygments.util import ClassNotFound from six.moves.http_cookies import SimpleCookie @@ -48,7 +48,7 @@ cookie = SimpleCookie(base_value) for k, v in cookies.items(): cookie[k] = v - return str(cookie.output(header='', sep=';').lstrip()) + return cookie.output(header='', sep=';').lstrip() class ExecutionListener(object): @@ -89,7 +89,7 @@ callback=normalize_url) @click.option('--env', help="Environment file to preload.", type=click.Path(exists=True)) -@click.argument('url', default='') +@click.argument('url', default='http://localhost:8000') @click.argument('http_options', nargs=-1, type=click.UNPROCESSED) @click.version_option(message='%(version)s') def cli(spec, env, url, http_options): @@ -119,8 +119,7 @@ finally: f.close() - if url: - url = fix_incomplete_url(url) + url = fix_incomplete_url(url) context = Context(url, spec=spec) output_style = cfg.get('output_style') @@ -135,7 +134,7 @@ style_class = get_style_by_name(cfg['command_style']) except ClassNotFound: style_class = Solarized256Style - style = style_from_pygments(style_class) + style = style_from_pygments_cls(style_class) listener = ExecutionListener(cfg) @@ -145,8 +144,8 @@ else: if env: load_context(context, env) - if url: - # Overwrite the env url if not default + if url != 'http://localhost:8000': + # overwrite the env url if not default context.url = url if http_options: @@ -159,7 +158,9 @@ text = prompt('%s> ' % context.url, completer=completer, lexer=lexer, style=style, history=history, auto_suggest=AutoSuggestFromHistory(), - on_abort=AbortAction.RETRY, vi_mode=cfg['vi']) + vi_mode=cfg['vi']) + except KeyboardInterrupt: + continue # Control-C pressed except EOFError: break # Control-D pressed else: