nicolaferraro closed pull request #2: Add bash completion
URL: https://github.com/apache/camel-k/pull/2
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/Gopkg.lock b/Gopkg.lock
index 203e5c3..cf518d5 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 6f4c258..be575a3 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
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to