Skip to content

Commit e7014d2

Browse files
authored
fix(core): disable colors on non-human output (#113)
- disable colors on non-human output - remove extra space after server IP - add `.vscode` to .gitignore
1 parent 8f5ee5e commit e7014d2

4 files changed

Lines changed: 13 additions & 7 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ vendor/
2727

2828
.DS_Store
2929
dist/
30+
31+
# Visual Studio Code
32+
.vscode
33+

internal/commands/server/show.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ func (s *showCommand) Execute(exec commands.Executor, uuid string) (output.Outpu
106106
for _, addr := range nic.IPAddresses {
107107
var floating string
108108
if addr.Floating.Bool() {
109-
floating = "(f)"
109+
floating = " (f)"
110110
}
111111

112112
addrs = append(
113113
addrs,
114114
fmt.Sprintf(
115-
"%v: %s %s",
115+
"%v: %s%s",
116116
addr.Family,
117117
ui.DefaultAddressColours.Sprint(addr.Address),
118118
floating),

internal/commands/server/show_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ func TestServerHumanOutput(t *testing.T) {
173173
174174
NICs: (Flags: S = source IP filtering, B = bootable)
175175
176-
# Type IP Address MAC Address Network Flags
177-
─── ───────── ──────────────────────────────────────────────────── ─────────────────── ────────────────────────────────────── ───────
178-
1 public IPv4: 94.237.0.207 de:ff:ff:ff:66:89 037fcf2a-6745-45dd-867e-f9479ea8c044
179-
2 utility IPv4: 10.6.3.95 (f) de:ff:ff:ff:ed:85 03000000-0000-4000-8045-000000000000
180-
3 public IPv6: xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx de:ff:ff:ff:cc:20 03c93fd8-cc60-4849-91b8-6e404b228e2a
176+
# Type IP Address MAC Address Network Flags
177+
─── ───────── ──────────────────────────────────────────────────── ─────────────────── ────────────────────────────────────── ───────
178+
1 public IPv4: 94.237.0.207 de:ff:ff:ff:66:89 037fcf2a-6745-45dd-867e-f9479ea8c044
179+
2 utility IPv4: 10.6.3.95 (f) de:ff:ff:ff:ed:85 03000000-0000-4000-8045-000000000000
180+
3 public IPv6: xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx de:ff:ff:ff:cc:20 03c93fd8-cc60-4849-91b8-6e404b228e2a
181181
182182
Firewall Rules:
183183

internal/core/core.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ func BuildRootCmd(conf *config.Config) cobra.Command {
3535
text.EnableColors()
3636
case conf.GlobalFlags.NoColours == config.True:
3737
text.DisableColors()
38+
case conf.GlobalFlags.OutputFormat != config.ValueOutputHuman:
39+
text.DisableColors()
3840
default:
3941
if terminal.IsStdoutTerminal() {
4042
text.EnableColors()

0 commit comments

Comments
 (0)