Skip to content
Merged
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
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ System Requirements
Python Packages
---------------
* six >= 1.7.0
* prettytable >= 0.7.0
* click >= 5, < 7
* requests >= 2.18.4
* prompt_toolkit >= 0.53
* ptable >= 0.9.2
* click >= 7
* requests >= 2.20.0
* prompt_toolkit >= 2
* pygments >= 2.0.0
* urllib3 >= 1.22
* urllib3 >= 1.24

Copyright
---------
Expand Down
5 changes: 2 additions & 3 deletions SoftLayer/shell/completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,17 @@ def get_completions(self, document, complete_event):
return _click_autocomplete(self.root, document.text_before_cursor)


# pylint: disable=stop-iteration-return
def _click_autocomplete(root, text):
"""Completer generator for click applications."""
try:
parts = shlex.split(text)
except ValueError:
raise StopIteration
return

location, incomplete = _click_resolve_command(root, parts)

if not text.endswith(' ') and not incomplete and text:
raise StopIteration
return

if incomplete and not incomplete[0:2].isalnum():
for param in location.params:
Expand Down
10 changes: 6 additions & 4 deletions SoftLayer/shell/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import traceback

import click
from prompt_toolkit import auto_suggest as p_auto_suggest
from prompt_toolkit import shortcuts as p_shortcuts
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
from prompt_toolkit import PromptSession

from SoftLayer.CLI import core
from SoftLayer.CLI import environment
Expand Down Expand Up @@ -48,12 +48,14 @@ def cli(ctx, env):
os.makedirs(app_path)
complete = completer.ShellCompleter(core.cli)

session = PromptSession()

while True:
try:
line = p_shortcuts.prompt(
line = session.prompt(
completer=complete,
complete_while_typing=True,
auto_suggest=p_auto_suggest.AutoSuggestFromHistory(),
auto_suggest=AutoSuggestFromHistory(),
)

# Parse arguments
Expand Down
4 changes: 2 additions & 2 deletions SoftLayer/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def set_mock(self, service, method):
"""Set and return mock on the current client."""
return self.mocks.set_mock(service, method)

def run_command(self, args=None, env=None, fixtures=True, fmt='json'):
def run_command(self, args=None, env=None, fixtures=True, fmt='json', stdin=None):
"""A helper that runs a SoftLayer CLI command.

This returns a click.testing.Result object.
Expand All @@ -169,7 +169,7 @@ def run_command(self, args=None, env=None, fixtures=True, fmt='json'):
args.insert(0, '--format=%s' % fmt)

runner = testing.CliRunner()
return runner.invoke(core.cli, args=args, obj=env or self.env)
return runner.invoke(core.cli, args=args, input=stdin, obj=env or self.env)


def call_has_props(call, props):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
'ptable >= 0.9.2',
'click >= 7',
'requests >= 2.20.0',
'prompt_toolkit >= 0.53',
'prompt_toolkit >= 2',
'pygments >= 2.0.0',
'urllib3 >= 1.24'
],
Expand Down
27 changes: 0 additions & 27 deletions tests/CLI/modules/shell_tests.py

This file was deleted.

2 changes: 1 addition & 1 deletion tools/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ six >= 1.7.0
ptable >= 0.9.2
click >= 7
requests >= 2.20.0
prompt_toolkit >= 0.53
prompt_toolkit >= 2
pygments >= 2.0.0
urllib3 >= 1.24
2 changes: 1 addition & 1 deletion tools/test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ six >= 1.7.0
ptable >= 0.9.2
click >= 7
requests >= 2.20.0
prompt_toolkit >= 0.53
prompt_toolkit >= 2
pygments >= 2.0.0
urllib3 >= 1.24