Compare commits
	
		
			2 Commits
		
	
	
		
			0.1.0
			...
			804ec99021
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						804ec99021
	
				 | 
					
					
						|||
| 
						
						
							
						
						ff05f8e2f3
	
				 | 
					
					
						
							
								
								
									
										32
									
								
								cmd/config.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								cmd/config.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					package lumecmd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
 | 
						"path"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const lumercFile string = ".lumerc"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func getConfigPath() string {
 | 
				
			||||||
 | 
						var tryPath, configPath string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// ~/.lumerc
 | 
				
			||||||
 | 
						homeDir, err := os.UserHomeDir()
 | 
				
			||||||
 | 
						if err == nil {
 | 
				
			||||||
 | 
							tryPath = path.Join(homeDir, lumercFile)
 | 
				
			||||||
 | 
							if _, err := os.Stat(tryPath); !os.IsNotExist(err) {
 | 
				
			||||||
 | 
								configPath = tryPath
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// ./.lumerc
 | 
				
			||||||
 | 
						cwd, err := os.Getwd()
 | 
				
			||||||
 | 
						if err == nil {
 | 
				
			||||||
 | 
							tryPath = path.Join(cwd, lumercFile)
 | 
				
			||||||
 | 
							if _, err := os.Stat(tryPath); !os.IsNotExist(err) {
 | 
				
			||||||
 | 
								configPath = tryPath
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return configPath
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										10
									
								
								cmd/ls.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								cmd/ls.go
									
									
									
									
									
								
							@@ -24,6 +24,8 @@ func NewCmdLs() Command {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func LsCmd(args CmdArgs) (int, error) {
 | 
					func LsCmd(args CmdArgs) (int, error) {
 | 
				
			||||||
 | 
						var p Printer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c := args.Client
 | 
						c := args.Client
 | 
				
			||||||
	selector := args.Flags.String("selector")
 | 
						selector := args.Flags.String("selector")
 | 
				
			||||||
	format := args.Flags.String("format")
 | 
						format := args.Flags.String("format")
 | 
				
			||||||
@@ -37,12 +39,8 @@ func LsCmd(args CmdArgs) (int, error) {
 | 
				
			|||||||
		return ExitFailure, err
 | 
							return ExitFailure, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch format {
 | 
						p = NewPrinter(format)
 | 
				
			||||||
	case "table":
 | 
						p.Lights(lights)
 | 
				
			||||||
		PrintLightsTable(lights)
 | 
					 | 
				
			||||||
	default:
 | 
					 | 
				
			||||||
		PrintLights(lights)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return ExitSuccess, nil
 | 
						return ExitSuccess, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										27
									
								
								cmd/main.go
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								cmd/main.go
									
									
									
									
									
								
							@@ -5,7 +5,6 @@ import (
 | 
				
			|||||||
	"flag"
 | 
						"flag"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"path"
 | 
					 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"git.kill0.net/chill9/lifx-go"
 | 
						"git.kill0.net/chill9/lifx-go"
 | 
				
			||||||
@@ -33,8 +32,6 @@ var Version string
 | 
				
			|||||||
var BuildDate string
 | 
					var BuildDate string
 | 
				
			||||||
var GitCommit string
 | 
					var GitCommit string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const lumercFile string = ".lumerc"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func Main(args []string) (int, error) {
 | 
					func Main(args []string) (int, error) {
 | 
				
			||||||
	var config Config
 | 
						var config Config
 | 
				
			||||||
	var err error
 | 
						var err error
 | 
				
			||||||
@@ -99,30 +96,6 @@ func Main(args []string) (int, error) {
 | 
				
			|||||||
	return exitCode, err
 | 
						return exitCode, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func getConfigPath() string {
 | 
					 | 
				
			||||||
	var tryPath, configPath string
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// ~/.lumerc
 | 
					 | 
				
			||||||
	homeDir, err := os.UserHomeDir()
 | 
					 | 
				
			||||||
	if err == nil {
 | 
					 | 
				
			||||||
		tryPath = path.Join(homeDir, lumercFile)
 | 
					 | 
				
			||||||
		if _, err := os.Stat(tryPath); !os.IsNotExist(err) {
 | 
					 | 
				
			||||||
			configPath = tryPath
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// ./.lumerc
 | 
					 | 
				
			||||||
	cwd, err := os.Getwd()
 | 
					 | 
				
			||||||
	if err == nil {
 | 
					 | 
				
			||||||
		tryPath = path.Join(cwd, lumercFile)
 | 
					 | 
				
			||||||
		if _, err := os.Stat(tryPath); !os.IsNotExist(err) {
 | 
					 | 
				
			||||||
			configPath = tryPath
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return configPath
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func initUserAgent() string {
 | 
					func initUserAgent() string {
 | 
				
			||||||
	var b strings.Builder
 | 
						var b strings.Builder
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,6 +29,8 @@ func NewCmdPoweroff() Command {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func PoweroffCmd(args CmdArgs) (int, error) {
 | 
					func PoweroffCmd(args CmdArgs) (int, error) {
 | 
				
			||||||
 | 
						var p Printer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c := args.Client
 | 
						c := args.Client
 | 
				
			||||||
	duration := args.Flags.Float64("duration")
 | 
						duration := args.Flags.Float64("duration")
 | 
				
			||||||
	selector := args.Flags.String("selector")
 | 
						selector := args.Flags.String("selector")
 | 
				
			||||||
@@ -44,12 +46,8 @@ func PoweroffCmd(args CmdArgs) (int, error) {
 | 
				
			|||||||
		return ExitFailure, err
 | 
							return ExitFailure, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch format {
 | 
						p = NewPrinter(format)
 | 
				
			||||||
	case "table":
 | 
						p.Results(r.Results)
 | 
				
			||||||
		PrintResultsTable(r.Results)
 | 
					 | 
				
			||||||
	default:
 | 
					 | 
				
			||||||
		PrintResults(r.Results)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return ExitSuccess, nil
 | 
						return ExitSuccess, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,6 +29,8 @@ func NewCmdPoweron() Command {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func PoweronCmd(args CmdArgs) (int, error) {
 | 
					func PoweronCmd(args CmdArgs) (int, error) {
 | 
				
			||||||
 | 
						var p Printer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c := args.Client
 | 
						c := args.Client
 | 
				
			||||||
	duration := args.Flags.Float64("duration")
 | 
						duration := args.Flags.Float64("duration")
 | 
				
			||||||
	selector := args.Flags.String("selector")
 | 
						selector := args.Flags.String("selector")
 | 
				
			||||||
@@ -44,12 +46,8 @@ func PoweronCmd(args CmdArgs) (int, error) {
 | 
				
			|||||||
		return ExitFailure, err
 | 
							return ExitFailure, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch format {
 | 
						p = NewPrinter(format)
 | 
				
			||||||
	case "table":
 | 
						p.Results(r.Results)
 | 
				
			||||||
		PrintResultsTable(r.Results)
 | 
					 | 
				
			||||||
	default:
 | 
					 | 
				
			||||||
		PrintResults(r.Results)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return ExitSuccess, nil
 | 
						return ExitSuccess, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										166
									
								
								cmd/print.go
									
									
									
									
									
								
							
							
						
						
									
										166
									
								
								cmd/print.go
									
									
									
									
									
								
							@@ -10,6 +10,98 @@ import (
 | 
				
			|||||||
	"github.com/olekukonko/tablewriter"
 | 
						"github.com/olekukonko/tablewriter"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type Printer interface {
 | 
				
			||||||
 | 
						Results(results []lifx.Result)
 | 
				
			||||||
 | 
						Lights(lights []lifx.Light)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type defaultPrinter struct{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type tablePrinter struct{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewPrinter(format string) Printer {
 | 
				
			||||||
 | 
						switch format {
 | 
				
			||||||
 | 
						case "table":
 | 
				
			||||||
 | 
							return &tablePrinter{}
 | 
				
			||||||
 | 
						default:
 | 
				
			||||||
 | 
							return &defaultPrinter{}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (dp *defaultPrinter) Results(results []lifx.Result) {
 | 
				
			||||||
 | 
						sortResults(results)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						table := tablewriter.NewWriter(os.Stdout)
 | 
				
			||||||
 | 
						_, rows := makeResultsTable(results)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for _, v := range rows {
 | 
				
			||||||
 | 
							table.Append(v)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						fmt.Printf("total %d\n", len(results))
 | 
				
			||||||
 | 
						table.SetAlignment(tablewriter.ALIGN_LEFT)
 | 
				
			||||||
 | 
						table.SetAutoWrapText(false)
 | 
				
			||||||
 | 
						table.SetBorder(false)
 | 
				
			||||||
 | 
						table.SetCenterSeparator("")
 | 
				
			||||||
 | 
						table.SetColumnSeparator("")
 | 
				
			||||||
 | 
						table.SetHeaderLine(false)
 | 
				
			||||||
 | 
						table.SetNoWhiteSpace(true)
 | 
				
			||||||
 | 
						table.SetRowSeparator("")
 | 
				
			||||||
 | 
						table.SetTablePadding(" ")
 | 
				
			||||||
 | 
						table.Render()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (tp *tablePrinter) Results(results []lifx.Result) {
 | 
				
			||||||
 | 
						sortResults(results)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						table := tablewriter.NewWriter(os.Stdout)
 | 
				
			||||||
 | 
						hdr, rows := makeResultsTable(results)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for _, v := range rows {
 | 
				
			||||||
 | 
							table.Append(v)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						table.SetHeader(hdr)
 | 
				
			||||||
 | 
						table.Render()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (dp *defaultPrinter) Lights(lights []lifx.Light) {
 | 
				
			||||||
 | 
						sortLights(lights)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						table := tablewriter.NewWriter(os.Stdout)
 | 
				
			||||||
 | 
						_, rows := makeLightsTable(lights)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for _, v := range rows {
 | 
				
			||||||
 | 
							table.Append(v)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						fmt.Printf("total %d\n", len(lights))
 | 
				
			||||||
 | 
						table.SetAlignment(tablewriter.ALIGN_LEFT)
 | 
				
			||||||
 | 
						table.SetAutoWrapText(false)
 | 
				
			||||||
 | 
						table.SetBorder(false)
 | 
				
			||||||
 | 
						table.SetCenterSeparator("")
 | 
				
			||||||
 | 
						table.SetColumnSeparator("")
 | 
				
			||||||
 | 
						table.SetHeaderLine(false)
 | 
				
			||||||
 | 
						table.SetNoWhiteSpace(true)
 | 
				
			||||||
 | 
						table.SetRowSeparator("")
 | 
				
			||||||
 | 
						table.SetTablePadding(" ")
 | 
				
			||||||
 | 
						table.Render()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (tp *tablePrinter) Lights(lights []lifx.Light) {
 | 
				
			||||||
 | 
						sortLights(lights)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						table := tablewriter.NewWriter(os.Stdout)
 | 
				
			||||||
 | 
						hdr, rows := makeLightsTable(lights)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for _, v := range rows {
 | 
				
			||||||
 | 
							table.Append(v)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						table.SetHeader(hdr)
 | 
				
			||||||
 | 
						table.Render()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func ColorizePower(s string) string {
 | 
					func ColorizePower(s string) string {
 | 
				
			||||||
	c := color.New(color.FgRed)
 | 
						c := color.New(color.FgRed)
 | 
				
			||||||
	if s == "on" {
 | 
						if s == "on" {
 | 
				
			||||||
@@ -69,77 +161,3 @@ func makeResultsTable(results []lifx.Result) (hdr []string, rows [][]string) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func PrintLights(lights []lifx.Light) {
 | 
					 | 
				
			||||||
	sortLights(lights)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	table := tablewriter.NewWriter(os.Stdout)
 | 
					 | 
				
			||||||
	_, rows := makeLightsTable(lights)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for _, v := range rows {
 | 
					 | 
				
			||||||
		table.Append(v)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	fmt.Printf("total %d\n", len(lights))
 | 
					 | 
				
			||||||
	table.SetAlignment(tablewriter.ALIGN_LEFT)
 | 
					 | 
				
			||||||
	table.SetAutoWrapText(false)
 | 
					 | 
				
			||||||
	table.SetBorder(false)
 | 
					 | 
				
			||||||
	table.SetCenterSeparator("")
 | 
					 | 
				
			||||||
	table.SetColumnSeparator("")
 | 
					 | 
				
			||||||
	table.SetHeaderLine(false)
 | 
					 | 
				
			||||||
	table.SetNoWhiteSpace(true)
 | 
					 | 
				
			||||||
	table.SetRowSeparator("")
 | 
					 | 
				
			||||||
	table.SetTablePadding(" ")
 | 
					 | 
				
			||||||
	table.Render()
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func PrintLightsTable(lights []lifx.Light) {
 | 
					 | 
				
			||||||
	sortLights(lights)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	table := tablewriter.NewWriter(os.Stdout)
 | 
					 | 
				
			||||||
	hdr, rows := makeLightsTable(lights)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for _, v := range rows {
 | 
					 | 
				
			||||||
		table.Append(v)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	table.SetHeader(hdr)
 | 
					 | 
				
			||||||
	table.Render()
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func PrintResults(results []lifx.Result) {
 | 
					 | 
				
			||||||
	sortResults(results)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	table := tablewriter.NewWriter(os.Stdout)
 | 
					 | 
				
			||||||
	_, rows := makeResultsTable(results)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for _, v := range rows {
 | 
					 | 
				
			||||||
		table.Append(v)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	fmt.Printf("total %d\n", len(results))
 | 
					 | 
				
			||||||
	table.SetAlignment(tablewriter.ALIGN_LEFT)
 | 
					 | 
				
			||||||
	table.SetAutoWrapText(false)
 | 
					 | 
				
			||||||
	table.SetBorder(false)
 | 
					 | 
				
			||||||
	table.SetCenterSeparator("")
 | 
					 | 
				
			||||||
	table.SetColumnSeparator("")
 | 
					 | 
				
			||||||
	table.SetHeaderLine(false)
 | 
					 | 
				
			||||||
	table.SetNoWhiteSpace(true)
 | 
					 | 
				
			||||||
	table.SetRowSeparator("")
 | 
					 | 
				
			||||||
	table.SetTablePadding(" ")
 | 
					 | 
				
			||||||
	table.Render()
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func PrintResultsTable(results []lifx.Result) {
 | 
					 | 
				
			||||||
	sortResults(results)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	table := tablewriter.NewWriter(os.Stdout)
 | 
					 | 
				
			||||||
	hdr, rows := makeResultsTable(results)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for _, v := range rows {
 | 
					 | 
				
			||||||
		table.Append(v)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	table.SetHeader(hdr)
 | 
					 | 
				
			||||||
	table.Render()
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -51,6 +51,8 @@ func NewCmdSetColor() Command {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func SetColorCmd(args CmdArgs) (int, error) {
 | 
					func SetColorCmd(args CmdArgs) (int, error) {
 | 
				
			||||||
 | 
						var p Printer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c := args.Client
 | 
						c := args.Client
 | 
				
			||||||
	state := lifx.State{}
 | 
						state := lifx.State{}
 | 
				
			||||||
	selector := args.Flags.String("selector")
 | 
						selector := args.Flags.String("selector")
 | 
				
			||||||
@@ -126,12 +128,8 @@ func SetColorCmd(args CmdArgs) (int, error) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if !fast {
 | 
						if !fast {
 | 
				
			||||||
		switch format {
 | 
							p = NewPrinter(format)
 | 
				
			||||||
		case "table":
 | 
							p.Results(r.Results)
 | 
				
			||||||
			PrintResultsTable(r.Results)
 | 
					 | 
				
			||||||
		default:
 | 
					 | 
				
			||||||
			PrintResults(r.Results)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return ExitSuccess, nil
 | 
						return ExitSuccess, nil
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,6 +44,8 @@ func NewCmdSetState() Command {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func SetStateCmd(args CmdArgs) (int, error) {
 | 
					func SetStateCmd(args CmdArgs) (int, error) {
 | 
				
			||||||
 | 
						var p Printer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c := args.Client
 | 
						c := args.Client
 | 
				
			||||||
	state := lifx.State{}
 | 
						state := lifx.State{}
 | 
				
			||||||
	selector := args.Flags.String("selector")
 | 
						selector := args.Flags.String("selector")
 | 
				
			||||||
@@ -92,12 +94,8 @@ func SetStateCmd(args CmdArgs) (int, error) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if !fast {
 | 
						if !fast {
 | 
				
			||||||
		switch format {
 | 
							p = NewPrinter(format)
 | 
				
			||||||
		case "table":
 | 
							p.Results(r.Results)
 | 
				
			||||||
			PrintResultsTable(r.Results)
 | 
					 | 
				
			||||||
		default:
 | 
					 | 
				
			||||||
			PrintResults(r.Results)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return ExitSuccess, nil
 | 
						return ExitSuccess, nil
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,6 +47,8 @@ func NewCmdSetWhite() Command {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func SetWhiteCmd(args CmdArgs) (int, error) {
 | 
					func SetWhiteCmd(args CmdArgs) (int, error) {
 | 
				
			||||||
 | 
						var p Printer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c := args.Client
 | 
						c := args.Client
 | 
				
			||||||
	state := lifx.State{}
 | 
						state := lifx.State{}
 | 
				
			||||||
	selector := args.Flags.String("selector")
 | 
						selector := args.Flags.String("selector")
 | 
				
			||||||
@@ -110,12 +112,8 @@ func SetWhiteCmd(args CmdArgs) (int, error) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if !fast {
 | 
						if !fast {
 | 
				
			||||||
		switch format {
 | 
							p = NewPrinter(format)
 | 
				
			||||||
		case "table":
 | 
							p.Results(r.Results)
 | 
				
			||||||
			PrintResultsTable(r.Results)
 | 
					 | 
				
			||||||
		default:
 | 
					 | 
				
			||||||
			PrintResults(r.Results)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return ExitSuccess, nil
 | 
						return ExitSuccess, nil
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,6 +27,8 @@ func NewCmdToggle() Command {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func ToggleCmd(args CmdArgs) (int, error) {
 | 
					func ToggleCmd(args CmdArgs) (int, error) {
 | 
				
			||||||
 | 
						var p Printer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c := args.Client
 | 
						c := args.Client
 | 
				
			||||||
	duration := args.Flags.Float64("duration")
 | 
						duration := args.Flags.Float64("duration")
 | 
				
			||||||
	selector := args.Flags.String("selector")
 | 
						selector := args.Flags.String("selector")
 | 
				
			||||||
@@ -41,12 +43,8 @@ func ToggleCmd(args CmdArgs) (int, error) {
 | 
				
			|||||||
		return ExitFailure, err
 | 
							return ExitFailure, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch format {
 | 
						p = NewPrinter(format)
 | 
				
			||||||
	case "table":
 | 
						p.Results(r.Results)
 | 
				
			||||||
		PrintResultsTable(r.Results)
 | 
					 | 
				
			||||||
	default:
 | 
					 | 
				
			||||||
		PrintResults(r.Results)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return ExitSuccess, nil
 | 
						return ExitSuccess, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user