Skip to content

Commit 1b85fff

Browse files
committed
Implemented broken printer os command
1 parent 7c1b839 commit 1b85fff

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

mima.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ func main() {
130130
if err != nil {
131131
return err
132132
}
133-
fmt.Println(os)
134-
//printer.PrintOS(os)
133+
printer.PrintOS(os)
135134

136135
return nil
137136
},

printer/printer.go

+19
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,22 @@ func PrintRegions(regions []providers.Region) {
5555
output += "└────────┴──────────────────────┘"
5656
fmt.Print(output)
5757
}
58+
59+
func PrintOS(os []providers.OS) {
60+
var output string
61+
output += "" +
62+
"┌────────┬──────────────────────┐\n" +
63+
"│ ID │ Name │\n" +
64+
"├────────┼──────────────────────┤\n"
65+
66+
sort.SliceStable(os, func(i, j int) bool {
67+
return os[i].Name[0] < os[j].Name[0]
68+
})
69+
70+
for _, region := range os {
71+
output += fmt.Sprintf("│ %-6v │ %20v │\n", region.ID, region.Name)
72+
}
73+
74+
output += "└────────┴──────────────────────┘"
75+
fmt.Print(output)
76+
}

0 commit comments

Comments
 (0)