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

R4R: add command to generate bash completion for gaia{d,cli} #3334

Merged
merged 4 commits into from
Jan 22, 2019

Conversation

alessio
Copy link
Contributor

@alessio alessio commented Jan 21, 2019

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.
  • Wrote tests
  • Updated relevant documentation (docs/)
  • Added entries in PENDING.md with issue #
  • rereviewed Files changed in the github PR explorer

For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@alessio alessio changed the title add command to generate bash completion for gaia{d,cli} R4R: add command to generate bash completion for gaia{d,cli} Jan 21, 2019
@cwgoes
Copy link
Contributor

cwgoes commented Jan 21, 2019

Is it possible to also generate zsh completion scripts (with a flag)?

@codecov
Copy link

codecov bot commented Jan 21, 2019

Codecov Report

Merging #3334 into develop will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff            @@
##           develop    #3334   +/-   ##
========================================
  Coverage    55.63%   55.63%           
========================================
  Files          132      132           
  Lines         9559     9559           
========================================
  Hits          5318     5318           
  Misses        3905     3905           
  Partials       336      336

@alessio
Copy link
Contributor Author

alessio commented Jan 21, 2019

@cwgoes done

Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commands work fine.

My zsh has some odd configuration so this should also be tested by someone with bash.

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing docs update

@alessio alessio requested a review from zramsay as a code owner January 21, 2019 17:03
@alessio
Copy link
Contributor Author

alessio commented Jan 21, 2019

@fedekunze done

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

gaiacli completion --zsh > gaiacli_completion
```

Refer to the user's manual of your interpreter for information
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is admirable, maybe we provide short examples of how to link it in your bash and zsh profiles?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

server/util.go Outdated
@@ -233,6 +233,38 @@ func UpgradeOldPrivValFile(config *cfg.Config) {
}
}

// NewCompletionCmd builds a cobra.Command that generate bash completion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this wants to live somewhere in the client folder? We need to do some thinking on CLI code organization.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@jackzampolin
Copy link
Member

Was able to get this working by saving the files as suggested and inserting them in my ~/.bash_profile using the following:

# Load gaiad and gaiacli completions
[[ -s "$HOME/.dotfiles/gaiad.bash" ]] && source $HOME/.dotfiles/gaiad.bash
[[ -s "$HOME/.dotfiles/gaiacli.bash" ]] && source $HOME/.dotfiles/gaiacli.bash

@cwgoes
Copy link
Contributor

cwgoes commented Jan 21, 2019

Was able to get this working by saving the files as suggested and inserting them in my ~/.bash_profile using the following:

# Load gaiad and gaiacli completions
[[ -s "$HOME/.dotfiles/gaiad.bash" ]] && source $HOME/.dotfiles/gaiad.bash
[[ -s "$HOME/.dotfiles/gaiacli.bash" ]] && source $HOME/.dotfiles/gaiacli.bash

Should we add this to docs? 👍

@alessio
Copy link
Contributor Author

alessio commented Jan 22, 2019

I'd strongly prefer avoiding explaining in detail or w/ examples where users should drop their interpreters config files - we would risk to make th gaiacli page turn into a Linux/MacOS for dummies man page. Why? 'Cause we would need to provide distinct examples for each interpreter and each Linux/Mac OS X - don't forget that very often shell interpreters behave differently on different systems - e.g the example posted by Jack might not work on some Linuxes (Bash on Mac ignores reads .bash_profile only, whilst Bash on most Linux distros that file is executed only for non interactive shell sessions). IMHO we'd better redirect them to their shell/operating system's manual pages.

@jackzampolin
Copy link
Member

@alessio point well taken. This looks great.

@jackzampolin jackzampolin merged commit cffa39c into develop Jan 22, 2019
@alessio alessio deleted the alessio/bash-completion branch January 22, 2019 03:45
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

Successfully merging this pull request may close these issues.

4 participants