Closed ghxiao closed 6 years ago
To support Bash completion you need to do the following:
@CompletionBehaviour
annotations to options/arguments that need them. Note that you don't have to add these annotations at all as the basic annotations provide enough information to generate a basic Bash completion scriptBashCompletionGenerator
and parse your GlobalMetadata
to it:
BashCompletionGenerator<Object> generator = new BashCompletionGenerator<>(); generator.usage(metadata, output);
This dumps the completion script to some OutputStream
instance here specified by the output
variable. Typically you will want this to be a FileOutputStream
I will leave this open as this definitely needs to be added to the new User Guide which I am currently working on - http://rvesse.github.io/airline/guide/ (#35)
Thanks a lot. I tried but stuck at constructing GlobalMetadata object. Is there some example on GlobalMetadata?
If you have created a parser for your CLI (i.e. you have a Cli
instance) then you can simply call getMetadata()
on this to get the meta-data. We don't currently have a way to generate completion for a SingleCommand
instance
Hoping to get a complete version of the User Guide prepared in the coming months so adding this to the next milestone
Now documented at http://rvesse.github.io/airline/guide/help/bash.html
Hi,
Thanks for this amazing project! I am using the airline library for the CLI of the ontop project. It works very well.
I noticed airline supports bash completion and want to use it in my project. However, I am not sure how to use it. I attached the
@CompletionBehaviour
annotations to some of the fields, but it seem not work. I guess I also need to generate a bash_completion file for bash. Maybe I overlooked something, but I searched around and could not found a guide. Is there some document or example code?Thanks in advance