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

fix: improve completions #1894

Merged
merged 1 commit into from Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/build.go
Expand Up @@ -37,6 +37,7 @@ func newBuildCmd() *buildCmd {
Short: "Builds the current project",
SilenceUsage: true,
SilenceErrors: true,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
start := time.Now()

Expand Down
1 change: 1 addition & 0 deletions cmd/check.go
Expand Up @@ -25,6 +25,7 @@ func newCheckCmd() *checkCmd {
Short: "Checks if configuration is valid",
SilenceUsage: true,
SilenceErrors: true,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
cfg, err := loadConfig(root.config)
if err != nil {
Expand Down
42 changes: 37 additions & 5 deletions cmd/completion.go
Expand Up @@ -9,11 +9,43 @@ type completionCmd struct {
func newCompletionCmd() *completionCmd {
var root = &completionCmd{}
var cmd = &cobra.Command{
Use: "completion",
Short: "Print shell autocompletion scripts for goreleaser",
SilenceUsage: true,
ValidArgs: []string{"bash", "zsh", "fish"},
Args: cobra.ExactValidArgs(1),
Use: "completion [bash|zsh|fish]",
Short: "Print shell autocompletion scripts for goreleaser",
Long: `To load completions:

Bash:

$ source <(goreleaser completion bash)

# To load completions for each session, execute once:
Linux:
$ goreleaser completion bash > /etc/bash_completion.d/goreleaser
MacOS:
$ goreleaser completion bash > /usr/local/etc/bash_completion.d/goreleaser

Zsh:

# If shell completion is not already enabled in your environment you will need
# to enable it. You can execute the following once:

$ echo "autoload -U compinit; compinit" >> ~/.zshrc

# To load completions for each session, execute once:
$ goreleaser completion zsh > "${fpath[1]}/_goreleaser"

# You will need to start a new shell for this setup to take effect.

Fish:

$ goreleaser completion fish | source

# To load completions for each session, execute once:
$ goreleaser completion fish > ~/.config/fish/completions/goreleaser.fish
`,
SilenceUsage: true,
DisableFlagsInUseLine: true,
ValidArgs: []string{"bash", "zsh", "fish"},
Args: cobra.ExactValidArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
var err error
switch args[0] {
Expand Down
1 change: 1 addition & 0 deletions cmd/init.go
Expand Up @@ -22,6 +22,7 @@ func newInitCmd() *initCmd {
Short: "Generates a .goreleaser.yml file",
SilenceUsage: true,
SilenceErrors: true,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
f, err := os.OpenFile(root.config, os.O_WRONLY|os.O_CREATE|os.O_TRUNC|os.O_EXCL, 0644)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/release.go
Expand Up @@ -41,6 +41,7 @@ func newReleaseCmd() *releaseCmd {
Short: "Releases the current project",
SilenceUsage: true,
SilenceErrors: true,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
start := time.Now()

Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Expand Up @@ -62,6 +62,7 @@ func newRootCmd(version string, exit func(int)) *rootCmd {
Version: version,
SilenceUsage: true,
SilenceErrors: true,
Args: cobra.NoArgs,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if root.debug {
log.SetLevel(log.DebugLevel)
Expand Down