git-project-manager/cmd/project_show.go

45 lines
990 B
Go
Raw Normal View History

2023-12-08 21:52:26 +00:00
package cmd
import (
"fmt"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
)
var projectShowCmd = &cobra.Command{
Use: "show [fuzzy alias search]",
Short: "Show detail for a GitLab project",
Args: cobra.ArbitraryArgs,
ValidArgsFunction: validProjectsOrAliasesFunc,
Long: projShowCmdLong,
Run: projectShowCmdRun,
}
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(pterm.LightGreen("\n--------------"))
fmt.Println(cache.ProjectString(project))
fmt.Println(pterm.LightGreen("--------------\n"))
}
func init() {
projectCmd.AddCommand(projectShowCmd)
}