mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
update setup install cmd info (#143)
* update setup install cmd info * update demo * add doc comment
This commit is contained in:
@@ -55,6 +55,7 @@ func NewInstallCommand() *cobra.Command {
|
||||
return fmt.Errorf("failed to write template config: %w", err)
|
||||
}
|
||||
|
||||
ui.PrintSetupInstallCmdInfo(aliasManager.GetRcPath(), config.Get().ConfigDir())
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 159 KiB After Width: | Height: | Size: 174 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 162 KiB After Width: | Height: | Size: 172 KiB |
@@ -112,7 +112,7 @@ func New(config AliasConfig, rcFileManager RcFileManager) *AliasManager {
|
||||
// Install creates the RC file with aliases and sources it in shell configurations.
|
||||
func (a *AliasManager) Install() error {
|
||||
aliases := a.buildAliases()
|
||||
rcPath, err := a.rcFileManager.Create(aliases)
|
||||
_, err := a.rcFileManager.Create(aliases)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create alias file: %w", err)
|
||||
}
|
||||
@@ -122,10 +122,6 @@ func (a *AliasManager) Install() error {
|
||||
return fmt.Errorf("failed to update shell configs: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("%s %s\n", ui.Colors.Green("✓"), "PMG aliases installed successfully")
|
||||
fmt.Printf(" %s\n", ui.Colors.Dim(fmt.Sprintf("Created: %s", rcPath)))
|
||||
fmt.Printf(" %s\n", ui.Colors.Dim("Restart your terminal or source your shell to use the new aliases"))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -143,6 +139,11 @@ func (a *AliasManager) Remove() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetRcPath returns the path to the alias RC file managed by AliasManager.
|
||||
func (a *AliasManager) GetRcPath() string {
|
||||
return a.rcFileManager.GetRcPath()
|
||||
}
|
||||
|
||||
// IsInstalled checks if the PMG aliases are sourced in any of the shell config files.
|
||||
func (a *AliasManager) IsInstalled() (bool, error) {
|
||||
homeDir, err := os.UserHomeDir()
|
||||
|
||||
@@ -23,3 +23,11 @@ func PrintInfoSection(title string, entries map[string]string) {
|
||||
fmt.Printf("%-25s: %s\n", Colors.Bold(k), entries[k])
|
||||
}
|
||||
}
|
||||
|
||||
// PrintSetupInstallCmdInfo prints a success message with the alias & config path, and a restart reminder.
|
||||
func PrintSetupInstallCmdInfo(rcPath, configPath string) {
|
||||
fmt.Printf("%s %s\n", Colors.Green("✓"), "PMG aliases installed successfully")
|
||||
fmt.Printf(" %s\n", Colors.Dim(fmt.Sprintf("Installed to: %s", rcPath)))
|
||||
fmt.Printf(" %s\n", Colors.Dim(fmt.Sprintf("Config at: %s", configPath)))
|
||||
fmt.Printf(" %s\n", Colors.Dim("Restart your terminal or source your shell to use the new aliases"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user