Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: jans-cli --no-suggestion for automated testing #1437

Merged
merged 1 commit into from
May 26, 2022
Merged
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
19 changes: 14 additions & 5 deletions jans-cli/cli/config_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
from types import SimpleNamespace
from urllib.parse import urlencode
from collections import OrderedDict
from prompt_toolkit import prompt, HTML
from prompt_toolkit.completion import WordCompleter

home_dir = Path.home()
config_dir = home_dir.joinpath('.config')
Expand Down Expand Up @@ -132,11 +130,18 @@ def join(self):
parser.add_argument("--patch-add", help="Colon delimited key:value pair for add patch operation. For example loggingLevel:DEBUG")
parser.add_argument("--patch-replace", help="Colon delimited key:value pair for replace patch operation. For example loggingLevel:DEBUG")
parser.add_argument("--patch-remove", help="Key for remove patch operation. For example imgLocation")
parser.add_argument("--no-suggestion", help="Do not use prompt toolkit to display word completer", action='store_true')

# parser.add_argument("-show-data-type", help="Show data type in schema query", action='store_true')
parser.add_argument("--data", help="Path to json data file")
args = parser.parse_args()


if not args.no_suggestion:
from prompt_toolkit import prompt, HTML
from prompt_toolkit.completion import WordCompleter


################## end of arguments #################

test_client = args.use_test_client
Expand Down Expand Up @@ -789,9 +794,13 @@ def get_input(self, values=[], text='Selection', default=None, itype=None,
values = ['_true', '_false']

while True:
#selection = input(' ' * spacing + self.colored_text(text, 20) + ' ')
html_completer = WordCompleter(values)
selection = prompt(HTML(' ' * spacing + text + ' '), completer=html_completer)

if args.no_suggestion:
selection = input(' ' * spacing + self.colored_text(text, 20) + ' ')
else:
html_completer = WordCompleter(values)
selection = prompt(HTML(' ' * spacing + text + ' '), completer=html_completer)

selection = selection.strip()
if selection.startswith('_file '):
fname = selection.split()[1]
Expand Down