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

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

Open
KSchopmeyer opened this issue Jun 8, 2023 · 3 comments
Open

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

KSchopmeyer opened this issue Jun 8, 2023 · 3 comments

Comments

@KSchopmeyer
Copy link

KSchopmeyer commented Jun 8, 2023

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'.

@KSchopmeyer
Copy link
Author

Since this worked in click-repl version 2.0, this is a serious backward incompatibility and actually makes this new release unusable to at least one of our projects.

@auvipy
Copy link
Collaborator

auvipy commented Jun 19, 2023

@GhostOps77 I guess you might know about the regression?

@KSchopmeyer
Copy link
Author

KSchopmeyer commented Sep 16, 2024

I do know of the regression and it means that our projects have to either stay with v2 or put the support of the general options back in ourselves. And with the long times to release things like click-repl, it will probably mean creating a fork or using a vendorzed version of click_repl. I tested this summer with our test suite and failed over a hundred of the test largely because we use the general options in the repl mode (A very simple example the --verbose option).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants