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

Bring flag arguments to subcommand? #143

Open
Arneball opened this issue Apr 13, 2021 · 7 comments
Open

Bring flag arguments to subcommand? #143

Arneball opened this issue Apr 13, 2021 · 7 comments

Comments

@Arneball
Copy link

Is there any way for a subcommands' prediction to get its parents flags?

For example

adb -s FA81Y1A02186 uninstall com.blabla

-s flag correctly predicts FA81Y1A02186.

However, if i in the handler want to predict what packages to uninstall, i need the predicted flag value from before. Because i want to query the specific device for packages that are installed.
Currently i can't. Maybe i've missed something.

@posener
Copy link
Owner

posener commented Apr 15, 2021

Hi,
Sorry, I don't understand the question.
In the above example, what is the flag, the subcommand and the predication?
What is currently possible and what would you like to be able to do?

The current behavior is that flags in a command will be available in all the subcommands and not the other way around. Does it make sense?

@Arneball
Copy link
Author

  • The flag for "install" is "-s", "FA81Y1A02186"
  • I want to bring FA81Y1A02186 to the subcommand "install"'s prediction function.
    Hope it clarifies a bit, can share a snippet otherwise.

@posener
Copy link
Owner

posener commented Apr 15, 2021

If -s is a flag of the root command, then it should be also completed for all sub commands. So adb uninstall com.blabla -s <tab> should complete in the same manner as adb -s <tab>. If this is not working for you, it is a bug. Can you provide some code that is not working and we can try and understand what is the issue?

@Arneball
Copy link
Author

Check this branch
https://github.com/Arneball/adb_bash_completions/tree/posener
Screenshot 2021-04-15 at 22 44 35

COMP_LINE="adb -s 192.168.1.64 uninstall " go run .

@Arneball
Copy link
Author

Arneball commented Apr 15, 2021

Arneball@a6a0011

Could this be something?

@posener
Copy link
Owner

posener commented Apr 17, 2021

Oh, I see, so you want that the root "args" will be completed in a subcommand "args".
This is a bit problematic - what happens when both the root command and the sub command have args. Usually the args will be a sub-command depended. And if they are common to two subcommands, they can share the same object in their Args vaule.
Does this make sense?

@Arneball
Copy link
Author

Arneball commented Apr 18, 2021

I don't think we have a mutual understanding :D

$ birdfeeder -type scavanger feed [cursor]
func getFood(a Args) []string {
	// Completion command for different food. Having the type of bird would be nice
}

Your issue is that feed subcommand could possibly define a type argument itself, thus polluting the prediction for the subcommand?

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