Skip to content

Commit 00cfefe

Browse files
committed
refactor(status): remove Network field from status output
feat(status): add Opt-in Attestations flag to status display style(shell): enhance upgrade warning with centered ASCII box
1 parent 676b9d0 commit 00cfefe

File tree

2 files changed

+47
-6
lines changed

2 files changed

+47
-6
lines changed

cmd/cli/commands/status/status.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,18 @@ func showStatus(
104104
fmt.Printf("%sContributoor Status%s\n", tui.TerminalColorLightBlue, tui.TerminalColorReset)
105105
fmt.Printf("%-20s: %s\n", "Version", current)
106106
fmt.Printf("%-20s: %s\n", "Run Method", cfg.RunMethod)
107-
fmt.Printf("%-20s: %s\n", "Network", cfg.NetworkName)
108107
fmt.Printf("%-20s: %s\n", "Beacon Node", cfg.BeaconNodeAddress)
109108
fmt.Printf("%-20s: %s\n", "Config Path", sidecarCfg.GetConfigPath())
110109

111110
if cfg.OutputServer != nil {
112111
fmt.Printf("%-20s: %s\n", "Output Server", cfg.OutputServer.Address)
113112
}
114113

114+
fmt.Printf(
115+
"%-20s: %v\n", "Opt-in Attestations",
116+
cfg.AttestationSubnetCheck != nil && cfg.AttestationSubnetCheck.Enabled,
117+
)
118+
115119
// Print running status with color.
116120
statusColor := tui.TerminalColorRed
117121
statusText := cases.Title(language.English).String(status)

internal/tui/shell.go

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,49 @@ func UpgradeWarning(currentVersion string, latestVersion string) {
5959
return
6060
}
6161

62-
fmt.Printf(
63-
"%sYou are running an old version of contributoor; we suggest you to update it to the latest version, '%s%s%s'. You can manually upgrade by running 'contributoor update'.%s\n\n",
64-
TerminalColorYellow,
62+
// Fixed box width
63+
boxWidth := 78
64+
65+
// Create the warning message parts
66+
line1 := "You are running an old version of contributoor;"
67+
line3 := "You can manually upgrade by running 'contributoor update'."
68+
69+
// Print the box
70+
fmt.Printf("\n%s╔%s╗\n", TerminalColorYellow, strings.Repeat("═", boxWidth))
71+
fmt.Printf("║%s║\n", strings.Repeat(" ", boxWidth))
72+
73+
// Center and print each line
74+
fmt.Printf("║%s║\n", centerText(line1, boxWidth))
75+
76+
// Print the version line with color
77+
versionPrefix := "we suggest you to update it to the latest version, '"
78+
versionSuffix := "'."
79+
totalLen := len(versionPrefix) + len(latestVersion) + len(versionSuffix)
80+
leftPad := (boxWidth - totalLen) / 2
81+
rightPad := boxWidth - totalLen - leftPad
82+
83+
fmt.Printf("║%s%s%s%s%s%s%s║\n",
84+
strings.Repeat(" ", leftPad),
85+
versionPrefix,
6586
TerminalColorLightBlue,
6687
latestVersion,
6788
TerminalColorYellow,
68-
TerminalColorReset,
69-
)
89+
versionSuffix,
90+
strings.Repeat(" ", rightPad))
91+
92+
fmt.Printf("║%s║\n", centerText(line3, boxWidth))
93+
94+
fmt.Printf("║%s║\n", strings.Repeat(" ", boxWidth))
95+
fmt.Printf("╚%s╝%s\n\n", strings.Repeat("═", boxWidth), TerminalColorReset)
96+
}
97+
98+
// centerText centers text within a given width.
99+
func centerText(text string, width int) string {
100+
if len(text) >= width {
101+
return text[:width]
102+
}
103+
104+
padding := (width - len(text)) / 2
105+
106+
return fmt.Sprintf("%s%s%s", strings.Repeat(" ", padding), text, strings.Repeat(" ", width-len(text)-padding))
70107
}

0 commit comments

Comments
 (0)