Skip to content

Commit

Permalink
Upgrade to prompt_toolkit 2.0 (#137)
Browse files Browse the repository at this point in the history
* Upgrade to prompt_toolkit 2.0

* A few small changes for being compatible with the latest prompt_toolkit 2.0

* Update requirements.txt

Co-authored-by: Jakub Roztocil <jakub@roztocil.co>
Co-authored-by: Mickaël Schoentgen <contact@tiger-222.fr>
  • Loading branch information
3 people committed Aug 5, 2021
1 parent dbe35f0 commit 6943959
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions http_prompt/cli.py
Expand Up @@ -13,11 +13,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

Expand Down Expand Up @@ -140,7 +140,7 @@ def cli(spec, env, url, http_options):
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)

Expand All @@ -164,7 +164,9 @@ def cli(spec, env, url, http_options):
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:
Expand Down
2 changes: 1 addition & 1 deletion http_prompt/utils.py
Expand Up @@ -4,7 +4,7 @@
import re
import shlex

from prompt_toolkit.shortcuts import create_output
from prompt_toolkit.output.defaults import create_output


RE_ANSI_ESCAPE = re.compile(r'\x1b[^m]*m')
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,6 +1,6 @@
click>=5.0
httpie>=2.4.0
parsimonious>=0.6.2
prompt-toolkit>=1.0.0,<2.0.0
prompt-toolkit>=2.0.0,<3.0.0
Pygments>=2.1.0
PyYAML>=3.0

0 comments on commit 6943959

Please sign in to comment.