diff --git a/src/cmd/listen.go b/src/cmd/listen.go index 79f567e..e13157f 100644 --- a/src/cmd/listen.go +++ b/src/cmd/listen.go @@ -16,7 +16,7 @@ var listenCmd = &cobra.Command{ Short: "listen command descritpion", Long: `listen command descritpion`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println("listen called") + fmt.Println("listen called with ID: ", cmd.Flag("id").Value) }, } @@ -31,5 +31,5 @@ func init() { // Cobra supports local flags which will only run when this command // is called directly, e.g.: - // listenCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + // listenCmd.Flags().Uint16("id", 0, "Identifier number") } diff --git a/src/cmd/motor.go b/src/cmd/motor.go index 2aaa438..623acc2 100644 --- a/src/cmd/motor.go +++ b/src/cmd/motor.go @@ -16,7 +16,7 @@ var motorCmd = &cobra.Command{ Short: "motor command descritpion", Long: `motor command descritpion`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println("motor called") + fmt.Println("motor called with ID: ", cmd.Flag("id").Value) }, } @@ -27,7 +27,8 @@ func init() { // Cobra supports Persistent Flags which will work for this command // and all subcommands, e.g.: - // motorCmd.PersistentFlags().String("foo", "", "A help for foo") + motorCmd.PersistentFlags().Uint16("id", 0, "Identifier number") + motorCmd.MarkFlagRequired("id") // Cobra supports local flags which will only run when this command // is called directly, e.g.: diff --git a/src/cmd/moveVel.go b/src/cmd/moveVel.go index be9e871..27c7b79 100644 --- a/src/cmd/moveVel.go +++ b/src/cmd/moveVel.go @@ -16,7 +16,7 @@ var moveVelCmd = &cobra.Command{ Short: "moveVel command descritpion", Long: `moveVel command descritpion`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println("moveVel called") + fmt.Println("moveVel called with: ID ", cmd.Flag("id").Value, " Vel ", cmd.Flag("vel").Value) }, } @@ -31,5 +31,6 @@ func init() { // Cobra supports local flags which will only run when this command // is called directly, e.g.: - // moveVelCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + //TODO: Anonymous flag (with anonymous flag group ?) + moveVelCmd.Flags().Float32("vel", 0, "Velocity (degrees/s)") } diff --git a/src/cmd/serve.go b/src/cmd/serve.go index aefab2c..60e32fe 100644 --- a/src/cmd/serve.go +++ b/src/cmd/serve.go @@ -21,7 +21,7 @@ Cobra is a CLI library for Go that empowers applications. This application is a tool to generate the needed files to quickly create a Cobra application.`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println("serve called") + fmt.Println("serve called with: Port ", cmd.Flag("port").Value, " - ID ", cmd.Flag("id").Value) }, } @@ -37,5 +37,7 @@ func init() { // Cobra supports local flags which will only run when this command // is called directly, e.g.: - // serveCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + serveCmd.Flags().Uint16P("port", "p", 8080, "Port") + + //TODO: Support Motor ID flag } diff --git a/src/cmd/setJoints.go b/src/cmd/setJoints.go index b1d0d4d..29b73d1 100644 --- a/src/cmd/setJoints.go +++ b/src/cmd/setJoints.go @@ -6,6 +6,7 @@ package cmd import ( "fmt" + // "strings" "github.com/spf13/cobra" ) @@ -16,7 +17,7 @@ var setJointsCmd = &cobra.Command{ Short: "setJoints command descritpion", Long: `setJoints command descritpion`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println("setJoints called") + fmt.Println("setJoints called with target :", cmd.Flag("vel").Value) }, } @@ -31,5 +32,8 @@ func init() { // Cobra supports local flags which will only run when this command // is called directly, e.g.: - // setJointsCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + //TODO: Anonymous flag (with anonymous flag group ?) + //TODO: Fix input of multiple values as slice + setJointsCmd.Flags().Float32Slice("vel", nil, "Target joint values") //or IntSlice ? + setJointsCmd.MarkFlagRequired("vel") }