Files
ax/cmd/show.go

33 lines
592 B
Go
Raw Normal View History

2026-03-26 12:48:47 +00:00
package cmd
import (
"axolotl/output"
2026-03-29 18:58:34 +02:00
"axolotl/service"
2026-03-26 12:48:47 +00:00
"fmt"
"os"
"github.com/spf13/cobra"
)
var showCmd = &cobra.Command{
Use: "show <id>", Short: "Show node details", Args: cobra.ExactArgs(1),
2026-03-26 12:48:47 +00:00
Run: func(cmd *cobra.Command, args []string) {
svc, err := service.GetNodeService(cfg)
2026-03-26 12:48:47 +00:00
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
n, err := svc.GetByID(args[0])
if err != nil {
2026-03-26 12:48:47 +00:00
fmt.Fprintln(os.Stderr, "node not found:", args[0])
os.Exit(1)
2026-03-26 12:48:47 +00:00
}
output.PrintNode(cmd.OutOrStdout(), svc, n, jsonFlag)
2026-03-26 12:48:47 +00:00
},
}
func init() {
rootCmd.AddCommand(showCmd)
}