add tests and refactor config creation

This commit is contained in:
Sahilb315
2025-12-16 23:52:51 +05:30
parent e19e190db7
commit 3a1afccb9e
4 changed files with 163 additions and 38 deletions
+3 -7
View File
@@ -14,7 +14,7 @@ func NewSetupCommand() *cobra.Command {
setupCmd := &cobra.Command{
Use: "setup",
Short: "Manage PMG shell aliases and integration",
Long: "Setup and manage PMG shell aliases that allow you to use 'npm', 'pnpm', 'pip' commands through PMG's security wrapper.",
Long: "Setup and manage PMG config and shell aliases that allow you to use 'npm', 'pnpm', 'pip' commands through PMG's security wrapper.",
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
},
@@ -29,8 +29,8 @@ func NewSetupCommand() *cobra.Command {
func NewInstallCommand() *cobra.Command {
return &cobra.Command{
Use: "install",
Short: "Install PMG aliases for package managers (npm, pnpm, pip)",
Long: "Creates ~/.pmg.rc with package manager aliases and sources it in your shell config files (.bashrc, .zshrc, config.fish)",
Short: "Setup PMG config and aliases for package managers (npm, pnpm, pip)",
Long: "",
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Print(ui.GeneratePMGBanner(version.Version, version.Commit))
@@ -39,10 +39,6 @@ func NewInstallCommand() *cobra.Command {
return fmt.Errorf("failed to create config dir: %s", err.Error())
}
if err := config.CreateConfig(); err != nil {
return err
}
cfg := alias.DefaultConfig()
rcFileManager, err := alias.NewDefaultRcFileManager(cfg.RcFileName)
if err != nil {