Files
ax/cmd/show.go

33 lines
637 B
Go
Raw Normal View History

2026-03-26 12:48:47 +00:00
package cmd
import (
"axolotl/db"
"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) {
d, err := db.GetDB()
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
2026-03-29 18:58:34 +02:00
svc := service.NewSQLiteNodeService(d.DB, cfg.GetUser())
if n, err := svc.GetByID(args[0]); err == nil {
output.PrintNode(cmd.OutOrStdout(), n, jsonFlag)
} else {
2026-03-26 12:48:47 +00:00
fmt.Fprintln(os.Stderr, "node not found:", args[0])
}
},
}
func init() {
rootCmd.AddCommand(showCmd)
}