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

Help of Bash Complemention #43

Closed
ghxiao opened this issue Jan 2, 2016 · 5 comments
Closed

Help of Bash Complemention #43

ghxiao opened this issue Jan 2, 2016 · 5 comments
Assignees
Labels
documentation Documentation Changes help Help System
Milestone

Comments

@ghxiao
Copy link

ghxiao commented Jan 2, 2016

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

@rvesse rvesse added this to the 2.1.1 milestone Jan 4, 2016
@rvesse rvesse added the help Help System label Jan 4, 2016
@rvesse
Copy link
Owner

rvesse commented Jan 4, 2016

To support Bash completion you need to do the following:

  • Add @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 script
  • Create an instance of BashCompletionGenerator 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
  • You then need to source the script in your environment

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)

@ghxiao ghxiao changed the title Help of Bash Complementiona Help of Bash Complemention Jan 4, 2016
@ghxiao
Copy link
Author

ghxiao commented Jan 5, 2016

Thanks a lot. I tried but stuck at constructing GlobalMetadata object. Is there some example on GlobalMetadata?

@rvesse
Copy link
Owner

rvesse commented Jan 5, 2016

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

@rvesse rvesse added the documentation Documentation Changes label Jan 18, 2016
@rvesse rvesse modified the milestones: 2.2.0, 2.1.1 Feb 9, 2016
@rvesse rvesse modified the milestones: Unscheduled, 2.2.0 Sep 13, 2016
@rvesse rvesse modified the milestones: Unscheduled, Next Feature Release (Q3 2018) Apr 10, 2018
@rvesse
Copy link
Owner

rvesse commented Apr 10, 2018

Hoping to get a complete version of the User Guide prepared in the coming months so adding this to the next milestone

@rvesse rvesse self-assigned this Apr 10, 2018
rvesse added a commit that referenced this issue Jul 26, 2018
@rvesse
Copy link
Owner

rvesse commented Jul 26, 2018

@rvesse rvesse closed this as completed Jul 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation Changes help Help System
Projects
None yet
Development

No branches or pull requests

2 participants