git-project-manager/cmd/project_show.go

41 lines
754 B
Go
Raw Normal View History

2023-12-08 21:52:26 +00:00
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
var projectShowCmd = &cobra.Command{
2023-12-10 04:45:30 +00:00
Use: "show [fuzzy alias search]",
Short: "Show detail for a GitLab project",
Args: cobra.ArbitraryArgs,
Long: projShowCmdLong,
Run: projectShowCmdRun,
2023-12-08 21:52:26 +00:00
}
func projectShowCmdRun(cmd *cobra.Command, args []string) {
var searchString string
if len(args) > 0 {
searchString = args[0]
}
project := fzfFindProject(searchString)
if project == nil {
var err error
project, err = fzfProject(cmd.Context())
if err != nil || project == nil {
plog.Fatal("Failed to find project, nothing to show", plog.Args(
"error", err,
))
}
}
fmt.Println(cache.ProjectString(project))
}
func init() {
projectCmd.AddCommand(projectShowCmd)
}