Update CLI
This commit is contained in:
parent
5b50ea8390
commit
b0a9be04aa
5 changed files with 18 additions and 10 deletions
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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.:
|
||||
|
|
|
@ -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)")
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue