fix: remote, sensor - list quiet
This commit is contained in:
parent
617454f66b
commit
99ff511117
@ -8,12 +8,14 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var quiet bool
|
||||
|
||||
var listRemoteCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List Remove Servers",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
if err := remote.Print(os.Stdout, configDir); err != nil {
|
||||
if err := remote.Print(os.Stdout, configDir, quiet); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
},
|
||||
@ -21,4 +23,6 @@ var listRemoteCmd = &cobra.Command{
|
||||
|
||||
func init() {
|
||||
remoteCmd.AddCommand(listRemoteCmd)
|
||||
|
||||
listRemoteCmd.Flags().BoolVarP(&quiet, "quiet", "q", false, "List only sensor id's")
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ func Disable(remoteName string, configDir string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func Print(w io.Writer, configDir string) error {
|
||||
func Print(w io.Writer, configDir string, quiet bool) error {
|
||||
|
||||
configuration, err := config.Read(configDir)
|
||||
if err != nil {
|
||||
@ -97,11 +97,17 @@ func Print(w io.Writer, configDir string) error {
|
||||
|
||||
tw := tabwriter.NewWriter(w, 0, 0, 3, ' ', 0)
|
||||
|
||||
if !quiet {
|
||||
fmt.Fprint(tw, "name\taddress\tenabled\tregistered\n")
|
||||
}
|
||||
|
||||
for _, remote := range configuration.Remotes {
|
||||
if quiet {
|
||||
fmt.Fprintf(tw, "%v\n", remote.Name)
|
||||
} else {
|
||||
fmt.Fprintf(tw, "%v\t%v\t%v\t%v\n", remote.Name, remote.Address, remote.Enabled, remote.Registered)
|
||||
}
|
||||
}
|
||||
|
||||
tw.Flush()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user