Rename project to git-project-manager
All checks were successful
Build and Publish / release (push) Successful in 1m10s

This commit is contained in:
2024-12-27 17:42:44 -05:00
parent 9dd38317b8
commit c78c41f567
51 changed files with 353 additions and 309 deletions

View File

@@ -4,6 +4,8 @@ import (
"context"
"os"
"os/signal"
"path/filepath"
"regexp"
"strings"
"github.com/pterm/pterm"
@@ -19,13 +21,15 @@ var (
)
var rootCmd = &cobra.Command{
Use: "gitlab-project-manager",
Use: "git-project-manager",
Aliases: []string{"gpm"},
Short: "Find and use GitLab projects locally",
Short: "Find and use Git projects locally",
Long: rootCmdLong,
PersistentPreRun: initRootCmd,
}
var configExemptCommands = regexp.MustCompile(`^(doc|conf)`)
// Hook traversal is enabled, so this will be run for all
// sub-commands regardless of their registered pre-hooks
func initRootCmd(cmd *cobra.Command, args []string) {
@@ -40,7 +44,7 @@ func Execute() {
err := rootCmd.ExecuteContext(ctx)
if err != nil {
pterm.Error.Printfln(pterm.LightYellow("Command failed, " + err.Error()))
pterm.Error.Printfln("%s", pterm.LightYellow("Command failed, "+err.Error()))
os.Exit(1)
}
}
@@ -77,10 +81,11 @@ func initConfig() {
home, err := os.UserHomeDir()
cobra.CheckErr(err)
// Search config in home directory with name ".gitlab-project-manager" (without extension).
viper.AddConfigPath(home + "/.config")
// Search config in home directory with name ".git-project-manager" (without extension).
configPath := filepath.Join(home, ".config")
viper.AddConfigPath(configPath)
viper.SetConfigType("yaml")
viper.SetConfigName("gitlab-project-manager")
viper.SetConfigName(getConfigName(configPath))
}
viper.AutomaticEnv()
@@ -100,13 +105,13 @@ func initConfig() {
plog.Error("Failed loading config", plog.Args("err", err))
}
if len(os.Args) > 0 && strings.HasPrefix(os.Args[1], "conf") {
if len(os.Args) > 0 && configExemptCommands.Match([]byte(os.Args[1])) {
plog.Debug("Permitting missing config for config sub-command")
return
} else if conf.ProjectPath == "" {
plog.Fatal("Minimal configuration missing, must have projectPath", plog.Args(
"do",
"Try running `gitlab-project-manager config default > "+defConfigPath,
"Try running `git-project-manager config default > "+defConfigPath,
))
}