Improve project show --current behavior
This commit is contained in:
parent
ea909b87cc
commit
b7960ed1b4
@ -2,6 +2,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/pterm/pterm"
|
"github.com/pterm/pterm"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -25,6 +26,7 @@ func projectShowCmdRun(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var project *gitlab.Project
|
var project *gitlab.Project
|
||||||
|
var inCwd bool
|
||||||
|
|
||||||
// Try to find project from current directory
|
// Try to find project from current directory
|
||||||
if viper.GetBool("project.show.current") {
|
if viper.GetBool("project.show.current") {
|
||||||
@ -37,6 +39,8 @@ func projectShowCmdRun(cmd *cobra.Command, args []string) {
|
|||||||
))
|
))
|
||||||
} else if project == nil {
|
} else if project == nil {
|
||||||
plog.Warn("Failed to use --current flag, project not found in current path")
|
plog.Warn("Failed to use --current flag, project not found in current path")
|
||||||
|
} else {
|
||||||
|
inCwd = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +67,11 @@ func projectShowCmdRun(cmd *cobra.Command, args []string) {
|
|||||||
WithTitle(pterm.Bold.Sprint(pterm.LightGreen("Project Information"))).
|
WithTitle(pterm.Bold.Sprint(pterm.LightGreen("Project Information"))).
|
||||||
Println(cache.ProjectString(project))
|
Println(cache.ProjectString(project))
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
|
if inCwd {
|
||||||
|
project.SetRepo(cache.OpenProject(cmd.Context(), project))
|
||||||
|
fmt.Fprintln(os.Stderr, project.GetGitInfo()+"\n")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
Loading…
Reference in New Issue
Block a user