Skip to content

Commit

Permalink
add more details to zones set command
Browse files Browse the repository at this point in the history
  • Loading branch information
tupyy committed Oct 25, 2023
1 parent 5aeec1d commit 687bab0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/zone/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var setCmd = &cobra.Command{
Use: "set temperature zone value",
Short: "Set temperature for a particular zone",
SilenceErrors: false,
SilenceUsage: true,
SilenceUsage: false,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 3 {
return errors.New("temperature arguments expected")
Expand Down
15 changes: 10 additions & 5 deletions cmd/zones/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,24 @@ import (

// setCmd represents the set command
var setCmd = &cobra.Command{
Use: "set",
Short: "Set temperature or mode for all zones",
SilenceErrors: true,
Use: "set [mode | temperature] [ modes | temperature ]",
Short: "Set temperature or mode for all zones",
Example: `
airzone zone set mode heating
airzone zone set temperature 21
`,
SilenceErrors: false,
SilenceUsage: false,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 2 {
if len(args)%2 != 0 {
return errors.New("temperature or mode arguments expected")
}

parameter := args[0]
outputValue := args[1]

if parameter != "temperature" && parameter != "mode" {
return fmt.Errorf("parameter to set %q unknown", parameter)
return fmt.Errorf("parameter %q unknown", parameter)
}

if parameter == "mode" {
Expand Down

0 comments on commit 687bab0

Please sign in to comment.