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)
|
Func: HelpCmd,
|
||||||
|
Flags: func() *flag.FlagSet {
|
||||||
|
fs := flag.NewFlagSet("help", flag.ExitOnError)
|
||||||
|
|
||||||
RegisterCommand(cmdName, Command{
|
return fs
|
||||||
Func: HelpCmd,
|
}(),
|
||||||
Flags: fs,
|
|
||||||
Use: "<command>",
|
Use: "<command>",
|
||||||
Short: "Show help for a command",
|
Short: "Show help for a command",
|
||||||
})
|
})
|
||||||
|
16
cmd/ls.go
16
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,
|
||||||
selector := fs.String("selector", defaultSelector, "Set the selector")
|
Flags: func() *flag.FlagSet {
|
||||||
fs.StringVar(selector, "s", defaultSelector, "Set the selector")
|
fs := flag.NewFlagSet("ls", flag.ExitOnError)
|
||||||
|
|
||||||
RegisterCommand(cmdName, Command{
|
selector := fs.String("selector", defaultSelector, "Set the selector")
|
||||||
Func: LsCmd,
|
fs.StringVar(selector, "s", defaultSelector, "Set the selector")
|
||||||
Flags: fs,
|
|
||||||
|
return fs
|
||||||
|
}(),
|
||||||
Use: "[--selector=<selector>]",
|
Use: "[--selector=<selector>]",
|
||||||
Short: "List the lights",
|
Short: "List the lights",
|
||||||
})
|
})
|
||||||
|
@ -7,19 +7,19 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
var cmdName string = "poweroff"
|
RegisterCommand("poweroff", Command{
|
||||||
|
Func: PoweroffCmd,
|
||||||
|
Flags: func() *flag.FlagSet {
|
||||||
|
fs := flag.NewFlagSet("poweroff", flag.ExitOnError)
|
||||||
|
|
||||||
fs := flag.NewFlagSet(cmdName, flag.ExitOnError)
|
duration := fs.Float64("duration", defaultDuration, "Set the duration")
|
||||||
|
fs.Float64Var(duration, "d", defaultDuration, "Set the duration")
|
||||||
|
|
||||||
duration := fs.Float64("duration", defaultDuration, "Set the duration")
|
selector := fs.String("selector", defaultSelector, "Set the selector")
|
||||||
fs.Float64Var(duration, "d", defaultDuration, "Set the duration")
|
fs.StringVar(selector, "s", defaultSelector, "Set the selector")
|
||||||
|
|
||||||
selector := fs.String("selector", defaultSelector, "Set the selector")
|
return fs
|
||||||
fs.StringVar(selector, "s", defaultSelector, "Set the selector")
|
}(),
|
||||||
|
|
||||||
RegisterCommand(cmdName, Command{
|
|
||||||
Func: PoweroffCmd,
|
|
||||||
Flags: fs,
|
|
||||||
Use: "[--selector <selector>] [--duration <sec>]",
|
Use: "[--selector <selector>] [--duration <sec>]",
|
||||||
Short: "Power on",
|
Short: "Power on",
|
||||||
})
|
})
|
||||||
|
@ -7,19 +7,19 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
var cmdName string = "poweron"
|
RegisterCommand("poweron", Command{
|
||||||
|
Func: PoweronCmd,
|
||||||
|
Flags: func() *flag.FlagSet {
|
||||||
|
fs := flag.NewFlagSet("poweron", flag.ExitOnError)
|
||||||
|
|
||||||
fs := flag.NewFlagSet(cmdName, flag.ExitOnError)
|
duration := fs.Float64("duration", defaultDuration, "Set the duration")
|
||||||
|
fs.Float64Var(duration, "d", defaultDuration, "Set the duration")
|
||||||
|
|
||||||
duration := fs.Float64("duration", defaultDuration, "Set the duration")
|
selector := fs.String("selector", defaultSelector, "Set the selector")
|
||||||
fs.Float64Var(duration, "d", defaultDuration, "Set the duration")
|
fs.StringVar(selector, "s", defaultSelector, "Set the selector")
|
||||||
|
|
||||||
selector := fs.String("selector", defaultSelector, "Set the selector")
|
return fs
|
||||||
fs.StringVar(selector, "s", defaultSelector, "Set the selector")
|
}(),
|
||||||
|
|
||||||
RegisterCommand(cmdName, Command{
|
|
||||||
Func: PoweronCmd,
|
|
||||||
Flags: fs,
|
|
||||||
Use: "[--selector <selector>] [--duration <sec>]",
|
Use: "[--selector <selector>] [--duration <sec>]",
|
||||||
Short: "Power on",
|
Short: "Power on",
|
||||||
})
|
})
|
||||||
|
@ -9,40 +9,40 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
var cmdName string = "set-color"
|
RegisterCommand("set-color", Command{
|
||||||
|
Func: SetColorCmd,
|
||||||
|
Flags: func() *flag.FlagSet {
|
||||||
|
fs := flag.NewFlagSet("set-color", flag.ExitOnError)
|
||||||
|
|
||||||
fs := flag.NewFlagSet(cmdName, flag.ExitOnError)
|
selector := fs.String("selector", "all", "the selector")
|
||||||
|
fs.StringVar(selector, "s", "all", "the selector")
|
||||||
|
|
||||||
selector := fs.String("selector", "all", "the selector")
|
power := fs.String("power", defaultPower, "power state")
|
||||||
fs.StringVar(selector, "s", "all", "the selector")
|
fs.StringVar(power, "p", defaultPower, "power state")
|
||||||
|
|
||||||
power := fs.String("power", defaultPower, "power state")
|
hue := fs.String("hue", defaultHue, "hue level")
|
||||||
fs.StringVar(power, "p", defaultPower, "power state")
|
fs.StringVar(hue, "H", defaultHue, "hue level")
|
||||||
|
|
||||||
hue := fs.String("hue", defaultHue, "hue level")
|
saturation := fs.String("saturation", defaultSaturation, "saturation level")
|
||||||
fs.StringVar(hue, "H", defaultHue, "hue level")
|
fs.StringVar(saturation, "S", defaultSaturation, "saturation level")
|
||||||
|
|
||||||
saturation := fs.String("saturation", defaultSaturation, "saturation level")
|
rgb := fs.String("rgb", defaultRGB, "RGB value")
|
||||||
fs.StringVar(saturation, "S", defaultSaturation, "saturation level")
|
fs.StringVar(rgb, "r", defaultRGB, "RGB value")
|
||||||
|
|
||||||
rgb := fs.String("rgb", defaultRGB, "RGB value")
|
name := fs.String("name", defaultName, "named color")
|
||||||
fs.StringVar(rgb, "r", defaultRGB, "RGB value")
|
fs.StringVar(name, "n", defaultName, "named color")
|
||||||
|
|
||||||
name := fs.String("name", defaultName, "named color")
|
brightness := fs.String("brightness", defaultBrightness, "brightness state")
|
||||||
fs.StringVar(name, "n", defaultName, "named color")
|
fs.StringVar(brightness, "b", defaultBrightness, "brightness state")
|
||||||
|
|
||||||
brightness := fs.String("brightness", defaultBrightness, "brightness state")
|
duration := fs.Float64("duration", defaultDuration, "duration state")
|
||||||
fs.StringVar(brightness, "b", defaultBrightness, "brightness state")
|
fs.Float64Var(duration, "d", defaultDuration, "duration state")
|
||||||
|
|
||||||
duration := fs.Float64("duration", defaultDuration, "duration state")
|
fast := fs.Bool("fast", defaultFast, "fast state")
|
||||||
fs.Float64Var(duration, "d", defaultDuration, "duration state")
|
fs.BoolVar(fast, "f", defaultFast, "fast state")
|
||||||
|
|
||||||
fast := fs.Bool("fast", defaultFast, "fast state")
|
return fs
|
||||||
fs.BoolVar(fast, "f", defaultFast, "fast state")
|
}(),
|
||||||
|
|
||||||
RegisterCommand(cmdName, Command{
|
|
||||||
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,34 +7,34 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
var cmdName string = "set-state"
|
RegisterCommand("set-state", Command{
|
||||||
|
Func: SetStateCmd,
|
||||||
|
Flags: func() *flag.FlagSet {
|
||||||
|
fs := flag.NewFlagSet("set-state", flag.ExitOnError)
|
||||||
|
|
||||||
fs := flag.NewFlagSet(cmdName, flag.ExitOnError)
|
selector := fs.String("selector", defaultSelector, "Set the selector")
|
||||||
|
fs.StringVar(selector, "s", defaultSelector, "Set the selector")
|
||||||
|
|
||||||
selector := fs.String("selector", defaultSelector, "Set the selector")
|
power := fs.String("power", defaultPower, "power state")
|
||||||
fs.StringVar(selector, "s", defaultSelector, "Set the selector")
|
fs.StringVar(power, "p", defaultPower, "power state")
|
||||||
|
|
||||||
power := fs.String("power", defaultPower, "power state")
|
color := fs.String("color", defaultColor, "color state")
|
||||||
fs.StringVar(power, "p", defaultPower, "power state")
|
fs.StringVar(color, "c", defaultColor, "color state")
|
||||||
|
|
||||||
color := fs.String("color", defaultColor, "color state")
|
brightness := fs.String("brightness", defaultBrightness, "brightness state")
|
||||||
fs.StringVar(color, "c", defaultColor, "color state")
|
fs.StringVar(brightness, "b", defaultBrightness, "brightness state")
|
||||||
|
|
||||||
brightness := fs.String("brightness", defaultBrightness, "brightness state")
|
duration := fs.Float64("duration", defaultDuration, "duration state")
|
||||||
fs.StringVar(brightness, "b", defaultBrightness, "brightness state")
|
fs.Float64Var(duration, "d", defaultDuration, "duration state")
|
||||||
|
|
||||||
duration := fs.Float64("duration", defaultDuration, "duration state")
|
infrared := fs.String("infrared", defaultInfrared, "infrared state")
|
||||||
fs.Float64Var(duration, "d", defaultDuration, "duration state")
|
fs.StringVar(infrared, "i", defaultInfrared, "infrared state")
|
||||||
|
|
||||||
infrared := fs.String("infrared", defaultInfrared, "infrared state")
|
fast := fs.Bool("fast", defaultFast, "fast state")
|
||||||
fs.StringVar(infrared, "i", defaultInfrared, "infrared state")
|
fs.BoolVar(fast, "f", defaultFast, "fast state")
|
||||||
|
|
||||||
fast := fs.Bool("fast", defaultFast, "fast state")
|
return fs
|
||||||
fs.BoolVar(fast, "f", defaultFast, "fast state")
|
}(),
|
||||||
|
|
||||||
RegisterCommand(cmdName, Command{
|
|
||||||
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,37 +7,37 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
var cmdName string = "set-white"
|
RegisterCommand("set-white", Command{
|
||||||
|
Func: SetWhiteCmd,
|
||||||
|
Flags: func() *flag.FlagSet {
|
||||||
|
fs := flag.NewFlagSet("set-white", flag.ExitOnError)
|
||||||
|
|
||||||
fs := flag.NewFlagSet(cmdName, flag.ExitOnError)
|
selector := fs.String("selector", "all", "the selector")
|
||||||
|
fs.StringVar(selector, "s", "all", "the selector")
|
||||||
|
|
||||||
selector := fs.String("selector", "all", "the selector")
|
power := fs.String("power", defaultPower, "power state")
|
||||||
fs.StringVar(selector, "s", "all", "the selector")
|
fs.StringVar(power, "p", defaultPower, "power state")
|
||||||
|
|
||||||
power := fs.String("power", defaultPower, "power state")
|
kelvin := fs.String("kelvin", defaultWhiteKelvin, "kelvin level")
|
||||||
fs.StringVar(power, "p", defaultPower, "power state")
|
fs.StringVar(kelvin, "k", defaultWhiteKelvin, "kelvin level")
|
||||||
|
|
||||||
kelvin := fs.String("kelvin", defaultWhiteKelvin, "kelvin level")
|
name := fs.String("name", defaultWhiteName, "named white level")
|
||||||
fs.StringVar(kelvin, "k", defaultWhiteKelvin, "kelvin level")
|
fs.StringVar(name, "n", defaultWhiteName, "named white level")
|
||||||
|
|
||||||
name := fs.String("name", defaultWhiteName, "named white level")
|
brightness := fs.String("brightness", defaultBrightness, "brightness state")
|
||||||
fs.StringVar(name, "n", defaultWhiteName, "named white level")
|
fs.StringVar(brightness, "b", defaultBrightness, "brightness state")
|
||||||
|
|
||||||
brightness := fs.String("brightness", defaultBrightness, "brightness state")
|
duration := fs.Float64("duration", defaultDuration, "duration state")
|
||||||
fs.StringVar(brightness, "b", defaultBrightness, "brightness state")
|
fs.Float64Var(duration, "d", defaultDuration, "duration state")
|
||||||
|
|
||||||
duration := fs.Float64("duration", defaultDuration, "duration state")
|
infrared := fs.String("infrared", defaultInfrared, "infrared state")
|
||||||
fs.Float64Var(duration, "d", defaultDuration, "duration state")
|
fs.StringVar(infrared, "i", defaultInfrared, "infrared state")
|
||||||
|
|
||||||
infrared := fs.String("infrared", defaultInfrared, "infrared state")
|
fast := fs.Bool("fast", defaultFast, "fast state")
|
||||||
fs.StringVar(infrared, "i", defaultInfrared, "infrared state")
|
fs.BoolVar(fast, "f", defaultFast, "fast state")
|
||||||
|
|
||||||
fast := fs.Bool("fast", defaultFast, "fast state")
|
return fs
|
||||||
fs.BoolVar(fast, "f", defaultFast, "fast state")
|
}(),
|
||||||
|
|
||||||
RegisterCommand(cmdName, Command{
|
|
||||||
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,19 +5,19 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
var cmdName string = "toggle"
|
RegisterCommand("toggle", Command{
|
||||||
|
Func: ToggleCmd,
|
||||||
|
Flags: func() *flag.FlagSet {
|
||||||
|
fs := flag.NewFlagSet("toggle", flag.ExitOnError)
|
||||||
|
|
||||||
fs := flag.NewFlagSet(cmdName, flag.ExitOnError)
|
duration := fs.Float64("duration", defaultDuration, "Set the duration")
|
||||||
|
fs.Float64Var(duration, "d", defaultDuration, "Set the duration")
|
||||||
|
|
||||||
duration := fs.Float64("duration", defaultDuration, "Set the duration")
|
selector := fs.String("selector", defaultSelector, "Set the selector")
|
||||||
fs.Float64Var(duration, "d", defaultDuration, "Set the duration")
|
fs.StringVar(selector, "s", defaultSelector, "Set the selector")
|
||||||
|
|
||||||
selector := fs.String("selector", defaultSelector, "Set the selector")
|
return fs
|
||||||
fs.StringVar(selector, "s", defaultSelector, "Set the selector")
|
}(),
|
||||||
|
|
||||||
RegisterCommand(cmdName, Command{
|
|
||||||
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