Skip to content

Does not allow use of general options in the repl #103

@KSchopmeyer

Description

@KSchopmeyer

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

Thus, if the app included a general option --verbose and the repl command looks like this "--verbose " click-repl accepted the --verbose general cmd line option.click-repl V2 allowed 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, or ':q' to exit pywbemcli or 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'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions