Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ListDeviceCmd = &cobra.Command{ Use: "list", Short: "list all devices linked to the account", PreRun: func(cmd *cobra.Command, args []string) { if account == "" { account = config.Config.DefaultAccount } if account == "" { common.Must(cmd.Help()) log.Fatal("No account specified. Please specify with --account or set a default") } }, Run: func(_ *cobra.Command, args []string) { go common.Signald.Listen(nil) req := v1.GetLinkedDevicesRequest{Account: account} resp, err := req.Submit(common.Signald) if err != nil { log.Fatal("error sending request to signald: ", err) } switch common.OutputFormat { case common.OutputFormatJSON: err := json.NewEncoder(os.Stdout).Encode(resp.Devices) if err != nil { log.Fatal(err, "error encoding response to stdout") } case common.OutputFormatYAML: err := yaml.NewEncoder(os.Stdout).Encode(resp.Devices) if err != nil { log.Fatal(err, "error encoding response to stdout") } case common.OutputFormatCSV, common.OutputFormatTable, common.OutputFormatDefault: t := table.NewWriter() t.SetOutputMirror(os.Stdout) t.AppendHeader(table.Row{"ID", "Name", "Last Seen", "Registered"}) for _, device := range resp.Devices { t.AppendRow(table.Row{device.ID, device.Name, device.LastSeen, device.Created}) } if common.OutputFormat == common.OutputFormatCSV { t.RenderCSV() } else { common.StylizeTable(t) t.Render() } default: log.Fatal("Unsupported output format") } }, } )
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.