Package subcommand code
This commit is contained in:
37
cmd/alias/alias.go
Normal file
37
cmd/alias/alias.go
Normal file
@@ -0,0 +1,37 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user