-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ add the possibility to remove elements
- Loading branch information
Showing
3 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
Copyright © 2023 Christian Ege <[email protected]> | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/graugans/go-ovp8xx/v2/pkg/ovp8xx" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func removeCommand(cmd *cobra.Command, args []string) error { | ||
p := args[0] | ||
host, err := rootCmd.PersistentFlags().GetString("ip") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
o3r := ovp8xx.NewClient( | ||
ovp8xx.WithHost(host), | ||
) | ||
|
||
return o3r.Remove(p) | ||
} | ||
|
||
// removeCmd represents the get command | ||
var removeCmd = &cobra.Command{ | ||
Use: "remove <pointer>", | ||
Short: "remove the OVP8xx", | ||
RunE: removeCommand, | ||
Args: func(cmd *cobra.Command, args []string) error { | ||
if len(args) != 1 { | ||
return fmt.Errorf("requires exactly one positional argument") | ||
} | ||
return nil | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(removeCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters