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

bug report: shell completion doesn't work with sub-commands v3-alpha4 #1814

Closed
3 tasks done
yogeshlonkar opened this issue Sep 11, 2023 · 2 comments · Fixed by #1824
Closed
3 tasks done

bug report: shell completion doesn't work with sub-commands v3-alpha4 #1814

yogeshlonkar opened this issue Sep 11, 2023 · 2 comments · Fixed by #1824
Labels
area/v3 relates to / is being considered for v3 status/triage maintainers still need to look into this

Comments

@yogeshlonkar
Copy link

yogeshlonkar commented Sep 11, 2023

Checklist

  • Are you running the latest v3 release? The list of releases is here.
  • Did you check the manual for your release? The v3 manual is here. Could not find the manual, link points to 404
  • Did you perform a search about this feature? Here's the GitHub guide about searching.

What problem does this solve?

If fixed, shell completion of sub-commands should work same as v2. For example:

mycli sub1 --generate-shell-completion

Instead of calling/ completing sub1 command the cli executes the action of sub1.

The issue is here https://github.com/urfave/cli/blob/v3.0.0-alpha4/help.go#L448-L455.

  • --generate-shell-completion is popped from arguments slice when checkShellCompleteFlag is run for mycli
  • In next recursive execution of Run for sub1 function checkShellCompleteFlag returns false as there is no --generate-shell-completion

Solution description

  • A separate recursive function is needed to find the last sub-command in chain.
  • If argument slice contains --generate-shell-completion the the last sub-command directly should be invoked for completion as it doesn't need chaining
  • Else Run should continue with existing steps

If the solution correct, I will try to provide a PR for this

@yogeshlonkar yogeshlonkar added area/v3 relates to / is being considered for v3 status/triage maintainers still need to look into this labels Sep 11, 2023
@dearchap
Copy link
Contributor

@yogeshlonkar This issue is present only in v3. If you look at v2 the shellComplete flag is set in context which is used to check later on. If you can add the flag back into context that would be great

@dearchap
Copy link
Contributor

@yogeshlonkar try this fix and see if it helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/v3 relates to / is being considered for v3 status/triage maintainers still need to look into this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants