34 lines
562 B
Go
34 lines
562 B
Go
|
|
package cmd
|
||
|
|
|
||
|
|
import (
|
||
|
|
"axolotl/db"
|
||
|
|
"axolotl/output"
|
||
|
|
"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) {
|
||
|
|
d, err := db.GetDB()
|
||
|
|
if err != nil {
|
||
|
|
fmt.Fprintln(os.Stderr, err)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
n, err := d.NodeByID(args[0])
|
||
|
|
if err != nil {
|
||
|
|
fmt.Fprintln(os.Stderr, "node not found:", args[0])
|
||
|
|
return
|
||
|
|
}
|
||
|
|
output.PrintNode(cmd.OutOrStdout(), n, jsonFlag)
|
||
|
|
},
|
||
|
|
}
|
||
|
|
|
||
|
|
func init() {
|
||
|
|
rootCmd.AddCommand(showCmd)
|
||
|
|
}
|