git-project-manager/cmd/alias/alias_list.go

40 lines
942 B
Go
Raw Permalink Normal View History

2024-12-30 19:54:32 +00:00
package alias
2023-12-09 04:13:17 +00:00
import (
"fmt"
2023-12-10 04:45:30 +00:00
"github.com/pterm/pterm"
2023-12-09 04:13:17 +00:00
"github.com/spf13/cobra"
"github.com/spf13/viper"
2024-12-31 22:45:45 +00:00
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
2023-12-09 04:13:17 +00:00
)
// listCmd represents the list command
var aliasListCmd = &cobra.Command{
Use: "list",
Aliases: []string{"dump", "show", "ls", "ll", "l"},
Short: "List Aliases",
2023-12-10 15:10:46 +00:00
PreRun: mustHaveAliases,
2024-12-30 19:54:32 +00:00
Long: util.AliasListCmdLong,
2023-12-09 04:13:17 +00:00
Run: runListAliasCmd,
}
func runListAliasCmd(cmd *cobra.Command, args []string) {
2024-12-30 20:50:31 +00:00
remotes := viper.GetStringSlice(util.FlagRemote)
2024-12-31 22:45:45 +00:00
aliases := utils.Cache().AliasesByProjectString(remotes...)
printer := pterm.DefaultBox.
2023-12-10 04:45:30 +00:00
WithLeftPadding(5).WithRightPadding(5).
WithBoxStyle(&pterm.Style{pterm.FgLightBlue}).
2024-12-31 22:45:45 +00:00
WithTitle(pterm.Bold.Sprint(pterm.LightGreen("Aliases by Project")))
if len(aliases) < 1 {
printer.Print("\n" + "No Aliases Found")
} else {
printer.Print("\n" + aliases)
}
2023-12-10 05:05:39 +00:00
fmt.Print("\n\n")
2023-12-09 04:13:17 +00:00
}