/
shelly_put_user_ca.go
35 lines (32 loc) · 1.06 KB
/
shelly_put_user_ca.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package cmd
import (
"github.com/jcodybaker/go-shelly"
"github.com/spf13/cobra"
)
var (
shellyPutUserCACmd = &cobra.Command{
Use: "put-user-ca",
}
)
func init() {
// Passing a whole cert as a cmd argument is awkward, but viper supports config files which
// should facilitate multi-line strings in yaml, JSON, etc.
shellyPutUserCACmd.Flags().String(
"data", "", "PEM encoded certificate authority data. (one of --data, --data-file, or --remove-ca is required)",
)
shellyPutUserCACmd.Flags().String(
"data-file", "", "path to a file containing PEM encoded certificate authority data.",
)
shellyPutUserCACmd.Flags().Bool(
"remove-ca", false, "remove an existing CA certificate from the device",
)
shellyComponent.Parent.AddCommand(shellyPutUserCACmd)
discoveryFlags(shellyPutUserCACmd.Flags(), discoveryFlagsOptions{interactive: true})
shellyPutUserCACmd.RunE = newDataCommand(
func(data *string, append bool) shelly.RPCRequestBody {
return &shelly.ShellyPutUserCARequest{
Data: data,
Append: append,
}
}, "data", "data-file", "remove-ca")
}