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