2020-11-17 05:41:34 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"go.jolheiser.com/tmpl/registry"
|
|
|
|
|
2021-11-02 03:22:27 +00:00
|
|
|
"github.com/rs/zerolog/log"
|
2020-11-17 05:41:34 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
var Remove = &cli.Command{
|
|
|
|
Name: "remove",
|
|
|
|
Usage: "Remove a template",
|
|
|
|
Description: "Remove a template from the registry",
|
2020-11-22 05:25:24 +00:00
|
|
|
ArgsUsage: "[name]",
|
2020-11-17 05:41:34 +00:00
|
|
|
Action: runRemove,
|
|
|
|
}
|
|
|
|
|
|
|
|
func runRemove(ctx *cli.Context) error {
|
|
|
|
if ctx.NArg() < 1 {
|
2020-11-22 05:25:24 +00:00
|
|
|
return cli.ShowCommandHelp(ctx, ctx.Command.Name)
|
2020-11-17 05:41:34 +00:00
|
|
|
}
|
|
|
|
|
2022-06-14 19:59:53 +00:00
|
|
|
reg, err := registry.Open(registryFlag)
|
2020-11-17 05:41:34 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := reg.RemoveTemplate(ctx.Args().First()); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-11-02 03:22:27 +00:00
|
|
|
log.Info().Msgf("Successfully removed %q", ctx.Args().First())
|
2020-11-17 05:41:34 +00:00
|
|
|
return nil
|
|
|
|
}
|