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

35 lines
867 B
Go
Raw Normal View History

2024-12-30 19:54:32 +00:00
package alias
2023-12-09 04:13:17 +00:00
import (
"fmt"
2024-12-30 19:54:32 +00:00
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
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"
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-10-01 18:29:14 +00:00
remotes := viper.GetStringSlice(FlagRemote)
2023-12-10 04:45:30 +00:00
pterm.DefaultBox.
WithLeftPadding(5).WithRightPadding(5).
WithBoxStyle(&pterm.Style{pterm.FgLightBlue}).
WithTitle(pterm.Bold.Sprint(pterm.LightGreen("Aliases by Project"))).
Print("\n" + projectCache.AliasesByProjectString(remotes...))
2023-12-10 05:05:39 +00:00
fmt.Print("\n\n")
2023-12-09 04:13:17 +00:00
}
func init() {
aliasCmd.AddCommand(aliasListCmd)
}