Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions cmd/cca/completion/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@
package completion

import (
"fmt"
"strings"

"github.com/cloud-ca/cca/cmd/cca/completion/bash"
"github.com/cloud-ca/cca/cmd/cca/completion/zsh"
"github.com/cloud-ca/cca/pkg/cmdutil"
"github.com/lithammer/dedent"
"github.com/spf13/cobra"
)

Expand All @@ -32,7 +28,7 @@ func NewCommand(gf *cmdutil.GlobalFlags) *cobra.Command {
Args: cobra.NoArgs,
Use: "completion",
Short: "Output completion code for the specified shell (bash or zsh)",
Long: strings.TrimLeft(dedent.Dedent(fmt.Sprint(`
Long: cmdutil.LongDescription(`
Outputs cca shell completion for the given shell (bash or zsh)
This depends on the bash-completion binary. Example installation instructions:

Expand All @@ -46,7 +42,7 @@ func NewCommand(gf *cmdutil.GlobalFlags) *cobra.Command {

Additionally, you may want to output the completion to a file and source in your .bashrc
Note for zsh users: [1] zsh completions are only supported in versions of zsh >= 5.2
`)), "\n"),
`),
}

cmd.AddCommand(zsh.NewCommand(gf))
Expand Down
14 changes: 14 additions & 0 deletions pkg/cmdutil/description.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package cmdutil

import (
"fmt"
"strings"

"github.com/lithammer/dedent"
)

// LongDescription formats long multi-line description and removes
// the left empty space from the lines
func LongDescription(a interface{}) string {
return strings.TrimLeft(dedent.Dedent(fmt.Sprint(a)), "\n")
}