(cmd *cobra.Command, args []string)
| 140 | } |
| 141 | |
| 142 | func runNodesShow(cmd *cobra.Command, args []string) error { |
| 143 | session, err := initCLISession(cmd) |
| 144 | if err != nil { |
| 145 | return printError(err) |
| 146 | } |
| 147 | |
| 148 | if session == nil { |
| 149 | return nil |
| 150 | } |
| 151 | |
| 152 | nodeName := args[0] |
| 153 | |
| 154 | nodes, err := session.getNodes(context.Background()) |
| 155 | if err != nil { |
| 156 | return printError(fmt.Errorf("failed to fetch nodes: %w", err)) |
| 157 | } |
| 158 | |
| 159 | for _, n := range nodes { |
| 160 | if n != nil && n.Name == nodeName { |
| 161 | out := nodeToOutput(n) |
| 162 | |
| 163 | if getOutputFormat(cmd) == outputTable { |
| 164 | printTable( |
| 165 | []string{"FIELD", "VALUE"}, |
| 166 | [][]string{ |
| 167 | {"Name", out.Name}, |
| 168 | {"IP", out.IP}, |
| 169 | {"Status", onlineStr(out.Online)}, |
| 170 | {"CPU Usage", fmt.Sprintf("%.1f%%", out.CPUUsage*100)}, |
| 171 | {"Memory Used", formatBytes(int64(out.MemoryUsed))}, |
| 172 | {"Memory Total", formatBytes(int64(out.MemoryTotal))}, |
| 173 | {"Uptime", formatUptime(out.Uptime)}, |
| 174 | {"Version", out.Version}, |
| 175 | {"Kernel", out.KernelVersion}, |
| 176 | }, |
| 177 | ) |
| 178 | |
| 179 | return nil |
| 180 | } |
| 181 | |
| 182 | return printJSON(out) |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | return printError(fmt.Errorf("node %q not found", nodeName)) |
| 187 | } |
| 188 | |
| 189 | // ── nodes shell ────────────────────────────────────────────────────────────── |
| 190 |
nothing calls this directly
no test coverage detected