Clean up subcommand registrations
This commit is contained in:
parent
320815293d
commit
9321095e11
11
cmd/help.go
11
cmd/help.go
@ -6,12 +6,13 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
var cmdName string = "help"
|
||||
fs := flag.NewFlagSet(cmdName, flag.ExitOnError)
|
||||
|
||||
RegisterCommand(cmdName, Command{
|
||||
RegisterCommand("help", Command{
|
||||
Func: HelpCmd,
|
||||
Flags: fs,
|
||||
Flags: func() *flag.FlagSet {
|
||||
fs := flag.NewFlagSet("help", flag.ExitOnError)
|
||||
|
||||
return fs
|
||||
}(),
|
||||
Use: "<command>",
|
||||
Short: "Show help for a command",
|
||||
})
|
||||
|
12
cmd/ls.go
12
cmd/ls.go
@ -5,14 +5,16 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
var cmdName string = "ls"
|
||||
fs := flag.NewFlagSet(cmdName, flag.ExitOnError)
|
||||
RegisterCommand("ls", Command{
|
||||
Func: LsCmd,
|
||||
Flags: func() *flag.FlagSet {
|
||||
fs := flag.NewFlagSet("ls", flag.ExitOnError)
|
||||
|
||||
selector := fs.String("selector", defaultSelector, "Set the selector")
|
||||
fs.StringVar(selector, "s", defaultSelector, "Set the selector")
|
||||
|
||||
RegisterCommand(cmdName, Command{
|
||||
Func: LsCmd,
|
||||
Flags: fs,
|
||||
return fs
|
||||
}(),
|
||||
Use: "[--selector=<selector>]",
|
||||
Short: "List the lights",
|
||||
})
|
||||
|
@ -7,9 +7,10 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
var cmdName string = "poweroff"
|
||||
|
||||
fs := flag.NewFlagSet(cmdName, flag.ExitOnError)
|
||||
RegisterCommand("poweroff", Command{
|
||||
Func: PoweroffCmd,
|
||||
Flags: func() *flag.FlagSet {
|
||||
fs := flag.NewFlagSet("poweroff", flag.ExitOnError)
|
||||
|
||||
duration := fs.Float64("duration", defaultDuration, "Set the duration")
|
||||
fs.Float64Var(duration, "d", defaultDuration, "Set the duration")
|
||||
@ -17,9 +18,8 @@ func init() {
|
||||
selector := fs.String("selector", defaultSelector, "Set the selector")
|
||||
fs.StringVar(selector, "s", defaultSelector, "Set the selector")
|
||||
|
||||
RegisterCommand(cmdName, Command{
|
||||
Func: PoweroffCmd,
|
||||
Flags: fs,
|
||||
return fs
|
||||
}(),
|
||||
Use: "[--selector <selector>] [--duration <sec>]",
|
||||
Short: "Power on",
|
||||
})
|
||||
|
@ -7,9 +7,10 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
var cmdName string = "poweron"
|
||||
|
||||
fs := flag.NewFlagSet(cmdName, flag.ExitOnError)
|
||||
RegisterCommand("poweron", Command{
|
||||
Func: PoweronCmd,
|
||||
Flags: func() *flag.FlagSet {
|
||||
fs := flag.NewFlagSet("poweron", flag.ExitOnError)
|
||||
|
||||
duration := fs.Float64("duration", defaultDuration, "Set the duration")
|
||||
fs.Float64Var(duration, "d", defaultDuration, "Set the duration")
|
||||
@ -17,9 +18,8 @@ func init() {
|
||||
selector := fs.String("selector", defaultSelector, "Set the selector")
|
||||
fs.StringVar(selector, "s", defaultSelector, "Set the selector")
|
||||
|
||||
RegisterCommand(cmdName, Command{
|
||||
Func: PoweronCmd,
|
||||
Flags: fs,
|
||||
return fs
|
||||
}(),
|
||||
Use: "[--selector <selector>] [--duration <sec>]",
|
||||
Short: "Power on",
|
||||
})
|
||||
|
@ -9,9 +9,10 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
var cmdName string = "set-color"
|
||||
|
||||
fs := flag.NewFlagSet(cmdName, flag.ExitOnError)
|
||||
RegisterCommand("set-color", Command{
|
||||
Func: SetColorCmd,
|
||||
Flags: func() *flag.FlagSet {
|
||||
fs := flag.NewFlagSet("set-color", flag.ExitOnError)
|
||||
|
||||
selector := fs.String("selector", "all", "the selector")
|
||||
fs.StringVar(selector, "s", "all", "the selector")
|
||||
@ -40,9 +41,8 @@ func init() {
|
||||
fast := fs.Bool("fast", defaultFast, "fast state")
|
||||
fs.BoolVar(fast, "f", defaultFast, "fast state")
|
||||
|
||||
RegisterCommand(cmdName, Command{
|
||||
Func: SetColorCmd,
|
||||
Flags: fs,
|
||||
return fs
|
||||
}(),
|
||||
Use: "[--selector <selector>] [--power (on|off)] [--hue <hue>] [--saturation <saturation>] [--rgb <rbg>] [--name <color>] [--brightness <brightness>] [--duration <sec>] [--fast]",
|
||||
Short: "Set the color",
|
||||
})
|
||||
|
@ -7,9 +7,10 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
var cmdName string = "set-state"
|
||||
|
||||
fs := flag.NewFlagSet(cmdName, flag.ExitOnError)
|
||||
RegisterCommand("set-state", Command{
|
||||
Func: SetStateCmd,
|
||||
Flags: func() *flag.FlagSet {
|
||||
fs := flag.NewFlagSet("set-state", flag.ExitOnError)
|
||||
|
||||
selector := fs.String("selector", defaultSelector, "Set the selector")
|
||||
fs.StringVar(selector, "s", defaultSelector, "Set the selector")
|
||||
@ -32,9 +33,8 @@ func init() {
|
||||
fast := fs.Bool("fast", defaultFast, "fast state")
|
||||
fs.BoolVar(fast, "f", defaultFast, "fast state")
|
||||
|
||||
RegisterCommand(cmdName, Command{
|
||||
Func: SetStateCmd,
|
||||
Flags: fs,
|
||||
return fs
|
||||
}(),
|
||||
Use: "[--selector <selector>] [--power (on|off)] [--color <color>] [--brightness <brightness>] [--duration <sec>] [--infrared <infrared>] [--fast]",
|
||||
Short: "Set various state attributes",
|
||||
})
|
||||
|
@ -7,9 +7,10 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
var cmdName string = "set-white"
|
||||
|
||||
fs := flag.NewFlagSet(cmdName, flag.ExitOnError)
|
||||
RegisterCommand("set-white", Command{
|
||||
Func: SetWhiteCmd,
|
||||
Flags: func() *flag.FlagSet {
|
||||
fs := flag.NewFlagSet("set-white", flag.ExitOnError)
|
||||
|
||||
selector := fs.String("selector", "all", "the selector")
|
||||
fs.StringVar(selector, "s", "all", "the selector")
|
||||
@ -35,9 +36,8 @@ func init() {
|
||||
fast := fs.Bool("fast", defaultFast, "fast state")
|
||||
fs.BoolVar(fast, "f", defaultFast, "fast state")
|
||||
|
||||
RegisterCommand(cmdName, Command{
|
||||
Func: SetWhiteCmd,
|
||||
Flags: fs,
|
||||
return fs
|
||||
}(),
|
||||
Use: "[--selector <selector>] [--power (on|off)] [--kelvin <kelvin>] [--name <color>] [--brightness <brightness>] [--duration <sec>] [--infrared] [--fast]",
|
||||
Short: "Set the white level",
|
||||
})
|
||||
|
@ -5,9 +5,10 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
var cmdName string = "toggle"
|
||||
|
||||
fs := flag.NewFlagSet(cmdName, flag.ExitOnError)
|
||||
RegisterCommand("toggle", Command{
|
||||
Func: ToggleCmd,
|
||||
Flags: func() *flag.FlagSet {
|
||||
fs := flag.NewFlagSet("toggle", flag.ExitOnError)
|
||||
|
||||
duration := fs.Float64("duration", defaultDuration, "Set the duration")
|
||||
fs.Float64Var(duration, "d", defaultDuration, "Set the duration")
|
||||
@ -15,9 +16,8 @@ func init() {
|
||||
selector := fs.String("selector", defaultSelector, "Set the selector")
|
||||
fs.StringVar(selector, "s", defaultSelector, "Set the selector")
|
||||
|
||||
RegisterCommand(cmdName, Command{
|
||||
Func: ToggleCmd,
|
||||
Flags: fs,
|
||||
return fs
|
||||
}(),
|
||||
Use: "[--selector <selector>] [--duration <sec>]",
|
||||
Short: "Toggle the power on/off",
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user