38 lines
884 B
Go
38 lines
884 B
Go
package alias
|
|
|
|
import (
|
|
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var AliasCmd = &cobra.Command{
|
|
Use: "alias",
|
|
Aliases: []string{"aliases", "a"},
|
|
Short: "Manage project aliases",
|
|
Long: util.AliasCmdLong,
|
|
// Just re-use the hooks for project
|
|
PersistentPreRun: util.InitProjects,
|
|
PersistentPostRun: util.PostProjectCmd,
|
|
}
|
|
|
|
var utils *util.Utils
|
|
|
|
func aliasCmdPreRun(cmd *cobra.Command, args []string) {
|
|
utils = util.MustFromCtx(cmd.Context())
|
|
util.InitProjects(cmd, args)
|
|
}
|
|
|
|
func mustHaveAliases(cmd *cobra.Command, args []string) {
|
|
utils := util.MustFromCtx(cmd.Context())
|
|
|
|
if len(utils.Cache().Aliases) == 0 {
|
|
utils.Logger().Fatal("No aliases set, nothing to " + cmd.Name())
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
AliasCmd.AddCommand(aliasAddCmd)
|
|
AliasCmd.AddCommand(aliasListCmd)
|
|
AliasCmd.AddCommand(aliasDeleteCmd)
|
|
}
|