complete
complete copied to clipboard
Bring flag arguments to subcommand?
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.
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?
- 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.
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?
Check this branch
https://github.com/Arneball/adb_bash_completions/tree/posener
COMP_LINE="adb -s 192.168.1.64 uninstall " go run .
https://github.com/Arneball/complete/commit/a6a001178d79f5ec7c2d977de90ca6cf52923250
Could this be something?
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?
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?