42 lines
862 B
Go
42 lines
862 B
Go
|
package cmd
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"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(cache.ProjectString(project))
|
||
|
}
|
||
|
|
||
|
func init() {
|
||
|
projectCmd.AddCommand(projectShowCmd)
|
||
|
}
|