MCPcopy Create free account
hub / github.com/diillson/chatcli / handleWatchStatusCommand

Method handleWatchStatusCommand

cli/command_handler_watch.go:147–181  ·  view source on GitHub ↗

handleWatchStatusCommand displays the current K8s watcher status.

(ctx context.Context)

Source from the content-addressed store, hash-verified

145
146// handleWatchStatusCommand displays the current K8s watcher status.
147func (ch *CommandHandler) handleWatchStatusCommand(ctx context.Context) {
148 // Check local watcher first
149 if ch.cli.isWatching {
150 if ch.cli.watchStatusFunc != nil {
151 status := ch.cli.watchStatusFunc()
152 fmt.Println(colorize(i18n.T("watch.status.active_with_info", status), ColorCyan))
153 } else {
154 fmt.Println(colorize(i18n.T("watch.status.active_no_info"), ColorCyan))
155 }
156 return
157 }
158
159 // If connected to remote, query server's watcher status
160 if ch.cli.isRemote {
161 if rc, ok := ch.cli.Client.(*remote.Client); ok {
162 ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
163 defer cancel()
164 ws, err := rc.GetWatcherStatus(ctx)
165 if err != nil {
166 fmt.Println(colorize(i18n.T("watch.error.remote_query_failed", err.Error()), ColorYellow))
167 return
168 }
169 if !ws.Active {
170 fmt.Println(colorize(i18n.T("watch.status.remote_inactive"), ColorYellow))
171 return
172 }
173 fmt.Println(colorize(i18n.T("watch.status.remote_active", ws.StatusSummary), ColorCyan))
174 fmt.Println(colorize(i18n.T("watch.status.remote_details",
175 ws.Namespace, ws.Deployment, ws.PodCount, ws.AlertCount, ws.SnapshotCount), ColorCyan))
176 return
177 }
178 }
179
180 fmt.Println(colorize(i18n.T("watch.status.inactive"), ColorYellow))
181}

Callers 1

handleWatchCommandMethod · 0.95

Calls 4

TFunction · 0.92
colorizeFunction · 0.85
GetWatcherStatusMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected