2025-07-19 20:58:05 +02:00
|
|
|
package subcommands
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2025-07-19 22:05:15 +02:00
|
|
|
"errors"
|
2025-07-19 20:58:05 +02:00
|
|
|
"github.com/urfave/cli/v3"
|
2025-07-19 22:05:15 +02:00
|
|
|
"log/slog"
|
2025-07-19 20:58:05 +02:00
|
|
|
)
|
|
|
|
|
|
2025-07-19 22:05:15 +02:00
|
|
|
var templateVar bool
|
2025-07-19 20:58:05 +02:00
|
|
|
|
|
|
|
|
// Template Command
|
|
|
|
|
func Template() *cli.Command {
|
|
|
|
|
return &cli.Command{
|
|
|
|
|
Name: "template command",
|
|
|
|
|
Usage: "template command usage",
|
|
|
|
|
Action: templateAction,
|
|
|
|
|
Flags: templateFlags(),
|
|
|
|
|
ArgsUsage: "args usage",
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// templateFlags Register cli flags
|
|
|
|
|
func templateFlags() []cli.Flag {
|
|
|
|
|
return []cli.Flag{
|
2025-07-19 22:05:15 +02:00
|
|
|
&cli.BoolFlag{
|
2025-07-19 20:58:05 +02:00
|
|
|
Name: "template",
|
|
|
|
|
Aliases: []string{"t"},
|
|
|
|
|
Usage: "usage",
|
2025-07-19 22:05:15 +02:00
|
|
|
Value: false,
|
|
|
|
|
DefaultText: "errors template",
|
2025-07-19 20:58:05 +02:00
|
|
|
Required: false,
|
|
|
|
|
Destination: &templateVar,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// templateAction logic for Template
|
|
|
|
|
func templateAction(context context.Context, c *cli.Command) error {
|
2025-07-19 22:05:15 +02:00
|
|
|
slog.InfoContext(context, "template called", "logLevel", "INFO")
|
|
|
|
|
slog.DebugContext(context, "template called", "logLevel", "DEBUG")
|
|
|
|
|
if templateVar {
|
|
|
|
|
slog.ErrorContext(context, "template called", "logLevel", "ERROR")
|
|
|
|
|
return errors.New("template called with error")
|
|
|
|
|
}
|
2025-07-19 20:58:05 +02:00
|
|
|
return nil
|
|
|
|
|
}
|