diff --git a/Gopkg.lock b/Gopkg.lock index 203e5c324e..cf518d58f0 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -585,6 +585,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "48fe81abc082944be87772c4562916fb9fe53b198f41ca770d84957d6b785516" + inputs-digest = "d79b669e9448950b8210a635a4857097167f8cdbec4ece89a268a3c881fbd61a" solver-name = "gps-cdcl" solver-version = 1 diff --git a/pkg/client/cmd/cmd.go b/pkg/client/cmd/cmd.go index 6f4c2583cb..be575a3ccf 100644 --- a/pkg/client/cmd/cmd.go +++ b/pkg/client/cmd/cmd.go @@ -18,29 +18,51 @@ limitations under the License. package cmd import ( - "github.com/spf13/cobra" - "github.com/apache/camel-k/pkg/client/cmd/version" + "os" + "github.com/apache/camel-k/pkg/client/cmd/run" + "github.com/apache/camel-k/pkg/client/cmd/version" + "github.com/spf13/cobra" ) -func NewKamelCommand() (*cobra.Command, error) { +const completionCmdLongDescription = ` +To load completion run - var rootCmd = cobra.Command{ - Use: "kamel", - Short: "Kamel is a awesome client tool for running Apache Camel integrations natively on Kubernetes", - Long: "Apache Camel K (a.k.a. Kamel) is a lightweight integration framework\nbuilt from Apache Camel that runs natively on Kubernetes and is\nspecifically designed for serverless and microservice architectures.", +. <(kamel completion) +To configure your bash shell to load completions for each session add to your bashrc + +# ~/.bashrc or ~/.profile +. <(kamel completion) +` + +func NewKamelCommand() (*cobra.Command, error) { + var cmd = cobra.Command{ + Use: "kamel", + Short: "Kamel is a awesome client tool for running Apache Camel integrations natively on Kubernetes", + Long: "Apache Camel K (a.k.a. Kamel) is a lightweight integration framework\nbuilt from Apache Camel that runs natively on Kubernetes and is\nspecifically designed for serverless and microservice architectures.", } var kubeconfig string - rootCmd.PersistentFlags().StringVar(&kubeconfig, "config", "", "Path to the config file to use for CLI requests") + cmd.PersistentFlags().StringVar(&kubeconfig, "config", "", "Path to the config file to use for CLI requests") // Initialize the Kubernetes client to allow using the operator-sdk - err := initKubeClient(&rootCmd) + err := initKubeClient(&cmd) if err != nil { return nil, err } - rootCmd.AddCommand(version.NewCmdVersion(), run.NewCmdRun()) - return &rootCmd, nil -} \ No newline at end of file + cmd.AddCommand(&cobra.Command{ + Use: "completion", + Short: "Generates bash completion scripts", + Long: completionCmdLongDescription, + Run: func(cmd *cobra.Command, args []string) { + cmd.GenBashCompletion(os.Stdout) + }, + }) + + cmd.AddCommand(version.NewCmdVersion()) + cmd.AddCommand(run.NewCmdRun()) + + return &cmd, nil +}