Use tablewriter for output formatting
This commit is contained in:
@ -41,6 +41,8 @@ func NewCmdSetColor() Command {
|
||||
fast := fs.Bool("fast", defaultFast, "fast state")
|
||||
fs.BoolVar(fast, "f", defaultFast, "fast state")
|
||||
|
||||
fs.String("format", defaultOutputFormat, "Set the output format")
|
||||
|
||||
return fs
|
||||
}(),
|
||||
Use: "[--selector <selector>] [--power (on|off)] [--hue <hue>] [--saturation <saturation>] [--rgb <rbg>] [--name <color>] [--brightness <brightness>] [--duration <sec>] [--fast]",
|
||||
@ -52,6 +54,11 @@ func SetColorCmd(args CmdArgs) (int, error) {
|
||||
c := args.Client
|
||||
state := lifx.State{}
|
||||
selector := args.Flags.String("selector")
|
||||
format := args.Flags.String("format")
|
||||
|
||||
if format == "" && args.Config.OutputFormat != "" {
|
||||
format = args.Config.OutputFormat
|
||||
}
|
||||
|
||||
power := args.Flags.String("power")
|
||||
if power != "" {
|
||||
@ -119,7 +126,12 @@ func SetColorCmd(args CmdArgs) (int, error) {
|
||||
}
|
||||
|
||||
if !fast {
|
||||
PrintResults(r.Results)
|
||||
switch format {
|
||||
case "table":
|
||||
PrintResultsTable(r.Results)
|
||||
default:
|
||||
PrintResults(r.Results)
|
||||
}
|
||||
}
|
||||
|
||||
return ExitSuccess, nil
|
||||
|
Reference in New Issue
Block a user