Support local project open

This commit is contained in:
Ryan McGuire 2023-12-19 11:08:12 -05:00
parent cf2f125e86
commit c45bc61e41

View File

@ -8,6 +8,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/gitlab"
)
var projectOpenCmd = &cobra.Command{
@ -58,11 +59,19 @@ func projectOpenCmdRun(cmd *cobra.Command, args []string) {
searchTerm = args[0]
}
// Find a project
project := fzfSearchProjectAliases(searchTerm)
// Try to open local project
var project *gitlab.Project
if searchTerm == "." {
project, _ = cache.GetProjectFromCwd()
}
// Find a project if not local
if project == nil {
project = fzfSearchProjectAliases(searchTerm)
if project == nil {
plog.Fatal("No project to open, nothing to do")
}
}
// Check the project
path := cache.GetProjectPath(project)