Package subcommand code

This commit is contained in:
2024-12-30 14:54:32 -05:00
parent 888ee5ea4a
commit 96378d047e
19 changed files with 564 additions and 412 deletions

34
cmd/alias/alias_list.go Normal file
View File

@@ -0,0 +1,34 @@
package alias
import (
"fmt"
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// listCmd represents the list command
var aliasListCmd = &cobra.Command{
Use: "list",
Aliases: []string{"dump", "show", "ls", "ll", "l"},
Short: "List Aliases",
PreRun: mustHaveAliases,
Long: util.AliasListCmdLong,
Run: runListAliasCmd,
}
func runListAliasCmd(cmd *cobra.Command, args []string) {
remotes := viper.GetStringSlice(FlagRemote)
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...))
fmt.Print("\n\n")
}
func init() {
aliasCmd.AddCommand(aliasListCmd)
}