Files
ax/cmd/show.go

31 lines
588 B
Go

package cmd
import (
"axolotl/output"
"axolotl/service"
"fmt"
"os"
"github.com/spf13/cobra"
)
var showCmd = &cobra.Command{
Use: "show <id>", Short: "Show node details", Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
svc, err := service.GetNodeService(cfg)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
if n, err := svc.GetByID(args[0]); err == nil {
output.PrintNode(cmd.OutOrStdout(), svc, n, jsonFlag)
} else {
fmt.Fprintln(os.Stderr, "node not found:", args[0])
}
},
}
func init() {
rootCmd.AddCommand(showCmd)
}