Skip to content

Commit

Permalink
refactor: ♿️ remove the -p argument for get/getSchema cli commands
Browse files Browse the repository at this point in the history
  • Loading branch information
graugans committed Jul 25, 2024
1 parent 3030965 commit 2c3dc5d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
4 changes: 2 additions & 2 deletions cmd/ovp8xx/cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func getCommand(cmd *cobra.Command, args []string) error {
ovp8xx.WithHost(helper.hostname()),
)

if result, err = o3r.Get(helper.jsonPointers()); err != nil {
if result, err = o3r.Get(args); err != nil {
return err
}
if err := helper.printJSONResult(result.String()); err != nil {
Expand All @@ -31,7 +31,7 @@ func getCommand(cmd *cobra.Command, args []string) error {

// getCmd represents the get command
var getCmd = &cobra.Command{
Use: "get",
Use: "get <pointers>",
Short: "Retrieve the JSON configuration from the device",
Long: `The OVP8xx get call accepts a list of JSON pointer like queries.
Valid queries are for example:
Expand Down
4 changes: 2 additions & 2 deletions cmd/ovp8xx/cmd/getSchema.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func getSchemaCommand(cmd *cobra.Command, args []string) error {
ovp8xx.WithHost(helper.hostname()),
)

if result, err = o3r.GetSchema(helper.jsonPointers()); err != nil {
if result, err = o3r.GetSchema(args); err != nil {
return err
}

Expand All @@ -31,7 +31,7 @@ func getSchemaCommand(cmd *cobra.Command, args []string) error {

// getCmd represents the get command
var getSchemaCmd = &cobra.Command{
Use: "getSchema",
Use: "getSchema [pointers]",
Short: "Retrieve the currently used JSON schema from the device",
Long: `The OVP8xx getSchema command accepts a list of JSON pointers.
The JSON schema provides details about multiple aspects of a parameter. It
Expand Down
6 changes: 0 additions & 6 deletions cmd/ovp8xx/cmd/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ func (c *helperConfig) hostname() string {
return c.host
}

func (c *helperConfig) jsonPointers() []string {
return c.pointers
}

func (c *helperConfig) remotePort() uint16 {
return c.port
}
Expand All @@ -56,8 +52,6 @@ func NewHelper(cmd *cobra.Command) (helperConfig, error) {
if err != nil {
return conf, err
}
// Pointers can be empty
conf.pointers, _ = cmd.Flags().GetStringSlice("pointer")

// Port can be empty
conf.port, err = cmd.Flags().GetUint16("port")
Expand Down

0 comments on commit 2c3dc5d

Please sign in to comment.