click-repl icon indicating copy to clipboard operation
click-repl copied to clipboard

Does not allow use of general options in the repl

Open KSchopmeyer opened this issue 1 year ago • 3 comments

If a command consists of general options (i.e. options before the command name), click_repl should support modifying them as part of a repl entered command.

Thus, if the command looks like tthis --verbose . It should allow the use both the options before the command and of tab-completion for these options and their values if the app code implements the tab-completion.

Right now, using the master branch entering any of these general options in the interactive mode ends up in a series of exceptions as shown below with the option to continue and eventually the command can be entered.

Example follows:

pywbemcli -n mock1 Enter 'help repl' for help, <CTRL-D> or ':q' to exit pywbemcli or <CTRL-r> to search history,

Unhandled exception in event loop: File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/prompt_toolkit/buffer.py", line 1933, in new_coroutine await coroutine(*a, **kw) File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/prompt_toolkit/buffer.py", line 1757, in async_completer async for completion in async_generator: File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/prompt_toolkit/completion/base.py", line 323, in get_completions_async async for completion in completer.get_completions_async( File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/prompt_toolkit/completion/base.py", line 199, in get_completions_async for item in self.get_completions(document, complete_event): File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/click_repl/_completer.py", line 257, in get_completions self.parsed_ctx = _resolve_context(args, self.ctx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/click_repl/utils.py", line 46, in resolve_context name, cmd, args = command.resolve_command(ctx, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/click/core.py", line 1715, in resolve_command ctx.fail(("No such command {name!r}.").format(name=original_cmd_name)) File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/click/core.py", line 679, in fail raise UsageError(message, self)

Exception No such command '-n'. Press ENTER to continue...

Unhandled exception in event loop: File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/prompt_toolkit/buffer.py", line 1933, in new_coroutine await coroutine(*a, **kw) File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/prompt_toolkit/buffer.py", line 1757, in async_completer async for completion in async_generator: File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/prompt_toolkit/completion/base.py", line 323, in get_completions_async async for completion in completer.get_completions_async( File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/prompt_toolkit/completion/base.py", line 199, in get_completions_async for item in self.get_completions(document, complete_event): File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/click_repl/_completer.py", line 257, in get_completions self.parsed_ctx = _resolve_context(args, self.ctx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/click_repl/utils.py", line 46, in resolve_context name, cmd, args = command.resolve_command(ctx, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/click/core.py", line 1715, in resolve_command ctx.fail(("No such command {name!r}.").format(name=original_cmd_name)) File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/click/core.py", line 679, in fail raise UsageError(message, self)

Exception No such command '-n'. Press ENTER to continue...

Unhandled exception in event loop: File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/prompt_toolkit/buffer.py", line 1933, in new_coroutine await coroutine(*a, **kw) File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/prompt_toolkit/buffer.py", line 1757, in async_completer async for completion in async_generator: File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/prompt_toolkit/completion/base.py", line 323, in get_completions_async async for completion in completer.get_completions_async( File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/prompt_toolkit/completion/base.py", line 199, in get_completions_async for item in self.get_completions(document, complete_event): File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/click_repl/_completer.py", line 257, in get_completions self.parsed_ctx = _resolve_context(args, self.ctx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/click_repl/utils.py", line 46, in resolve_context name, cmd, args = command.resolve_command(ctx, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/click/core.py", line 1715, in resolve_command ctx.fail(("No such command {name!r}.").format(name=original_cmd_name)) File "/home/kschopmeyer/virtualenvs/pycli311/lib/python3.11/site-packages/click/core.py", line 679, in fail raise UsageError(message, self)

Exception No such command '-n'. Press ENTER to continue... pywbemcli> -n mock3ns class enumerate Usage: pywbemcli [GENERAL-OPTIONS] COMMAND [ARGS] [COMMAND-OPTIONS]

Error: No such command '-n'.

KSchopmeyer avatar Jun 08 '23 17:06 KSchopmeyer