-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommandLsOs.go
More file actions
36 lines (29 loc) · 832 Bytes
/
commandLsOs.go
File metadata and controls
36 lines (29 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"fmt"
client "github.com/Virtomize/uii-go-api"
"os"
"text/tabwriter"
)
type lsOsCommand struct {
}
// Run executes the command to get a list of operating systems.
func (l *lsOsCommand) Run(ctx *context) error {
c, err := client.NewClient(ctx.token)
if err != nil {
return err
}
osList, err := c.OperatingSystems()
if err != nil {
return err
}
w := new(tabwriter.Writer)
w.Init(os.Stdout, 8, 8, 1, '\t', 0)
defer w.Flush()
fmt.Fprintf(w, "\n %s\t%s\t%s\t%s\t", "Displayname", "Distribution", "Version", "Architecture")
for _, osEntry := range osList {
fmt.Fprintf(w, "\n %s\t%s\t%s\t%s\t", osEntry.DisplayName, osEntry.Distribution, osEntry.Version, osEntry.Architecture)
}
fmt.Fprintf(w, "\n")
return nil
}