-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Before callback affects bash completions #1094
Comments
Is the idea that |
Hm, I think it all comes down to this. Yes. And I think the |
Interesting! Do you think the most of the people using that package have that same idea? I ask because if they don't, then this would be a breaking change for them. |
I would say yes. As provided in the example, the default behaviour of returning an error in Another problem would be printing anything in the I'm probably missing someone as I have mostly my own use-cases in mind but it seems like using To mitigate the breaking change (if anyone would be affected) new callbacks could be created: |
I could write a fix for that but I would need to know the decision: if we want to do it and if the approach of "skipping |
I would need to think about this a lot more before I can make this decision! Also cc @urfave/cli, in case anyone else has a more solid point of view here 🙏 |
To support my arguments here is my use-case: I use CLI to communicate with some server via API. To make sure that user correctly connected to the server I do pre-check which sends ping message to server. If that succeeds I set up the CLI and run the command, if not I print the error message. That works well but the problem is that if someone wants to do Also I was kind of surprised that |
Good call there. As of #1117 that is no longer the case. We don't put any documentation around what the intended purpose of I'd have two questions:
My guess to both of those are "no" and "no", and we'd be in a better spot if we didn't run I will also note that I have not used a |
Sounds awesome :)
That's my view as well. |
Any decision on this one? |
@lynncyrin if you had any thoughts here |
Agree with @VirrageS. Following the thread. |
This issue or PR has been automatically marked as stale because it has not had recent activity. Please add a comment bumping this if you're still interested in it's resolution! Thanks for your help, please let us know if you need anything else. |
Any updates on this ? |
This issue or PR has been bumped and is no longer marked as stale! Feel free to bump it again in the future, if it's still relevant. |
This issue or PR has been automatically marked as stale because it has not had recent activity. Please add a comment bumping this if you're still interested in it's resolution! Thanks for your help, please let us know if you need anything else. |
Closing this as it has become stale. |
Hello, probably related to this, if you have a flag that is required autocompletion for flags seems to break as well. |
@dbarrosop Thank you for reporting this! Are you seeing this behavior with the latest |
@meatballhat it still reproduces on latest release. |
@VirrageS I dont think this is an easy fix. All the Before functions are called before the CompletionFunc all the way down the chain . So none of the Before functions should be executed during command completion. |
Yup, that's sounds correct. |
@dearchap from what I see the PR targets v2. But the issue is raised for v1, which I currently use. |
@meatballhat, @dearchap any planned release for v1 with a fix? |
@talarian1 Its already merged to v1. Just waiting on @meatballhat to create a release tag. Thanks |
@dearchap hey sorry, on it now! |
- Bash completion was rewritten from scratch as `.Before` is no longer called by github.com/urface/cli since v1.22.10 (see urfave/cli#1094). There might be a better way to do so, but with the additions of stacks finding all "service.***" in the current porject path seemed like a good start. - Add a `.` alias in arg parsing allowing a stack or a service to be acted upon when the user is currently in its directory.
- Bash completion was updated to init services itself as `.Before` is no longer called by github.com/urface/cli since v1.22.10 (see urfave/cli#1094). - Add a `.` alias in arg parsing allowing a stack or a service to be acted upon when the user is currently in its directory.
my urfave/cli version is
v1.22.2, v1.22.3
Checklist
Dependency Management
Describe the bug
I wanted to introduce pre-check (with
.Before
callback) that would be run if the command is being executed. But it seems like the pre-check is also executed when I want to only show the completions for a given command what breaks the completions output if the.Before
has printed anything (in particular the error).To reproduce
example cmd [TAB]
Observed behavior
Expected behavior
Show completions for the given cmd:
Additional context
Looking at the code I've noticed that the commands are parsed/visited hierarchically and this also applies for the completions. But I'm not sure if the order should be as it is now. To me completions should be executed first even if the command is nested.
Run
go version
and paste its output hereThe text was updated successfully, but these errors were encountered: