You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
synctv/cmd/root/show.go

34 lines
716 B
Go

package root
import (
"fmt"
"github.com/spf13/cobra"
"github.com/synctv-org/synctv/internal/bootstrap"
"github.com/synctv-org/synctv/internal/db"
)
var ShowCmd = &cobra.Command{
Use: "show",
Short: "show root",
Long: `show root`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return bootstrap.New(bootstrap.WithContext(cmd.Context())).Add(
bootstrap.InitDiscardLog,
bootstrap.InitConfig,
bootstrap.InitDatabase,
).Run()
},
RunE: func(cmd *cobra.Command, args []string) error {
roots := db.GetRoots()
for _, root := range roots {
fmt.Printf("id: %s\tusername: %s\n", root.ID, root.Username)
}
return nil
},
}
func init() {
RootCmd.AddCommand(ShowCmd)
}