Skip to content

Commit

Permalink
Print usage for missing or unknown commands
Browse files Browse the repository at this point in the history
  • Loading branch information
tessro committed May 4, 2021
1 parent b663721 commit ddd46b8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,22 @@ type EffectsSelectRequest struct {
Select string `json:"select"`
}

func usage() {
fmt.Println("usage: picoleaf <command>")
fmt.Println()
fmt.Println("Commands:")
fmt.Println()
fmt.Println(" on Turn on Nanoleaf")
fmt.Println(" off Turn off Nanoleaf")
fmt.Println()
fmt.Println(" effect Control Nanoleaf effects")
fmt.Println()
fmt.Println(" hsl Set Nanoleaf to the provided HSL")
fmt.Println(" rgb Set Nanoleaf to the provided RGB")
fmt.Println()
os.Exit(1)
}

func main() {
flag.Parse()

Expand Down Expand Up @@ -236,7 +252,11 @@ func main() {
doRGBCommand(client, flag.Args()[1:])
case "effect":
doEffectCommand(client, flag.Args()[1:])
default:
usage()
}
} else {
usage()
}
}

Expand Down

0 comments on commit ddd46b8

Please sign in to comment.