template extended

This commit is contained in:
Darius 2024-05-24 12:21:21 +02:00
parent 66a5f3fb39
commit 6fefcbd4d1
3 changed files with 46 additions and 11 deletions

View File

@ -8,13 +8,14 @@ import (
func Boom() *cli.Command {
return &cli.Command{
Name: "boom",
Usage: "explode",
Action: boom,
Name: "boom",
Usage: "explode",
Aliases: []string{"b"},
Action: boom,
}
}
func boom(*cli.Context) error {
func boom(c *cli.Context) error {
fmt.Println("BOOM")
return nil
}

View File

@ -8,13 +8,39 @@ import (
func Template() *cli.Command {
return &cli.Command{
Name: "NAME",
Usage: "USAGE OF COMMAND",
Action: template,
Name: "NAME",
Usage: "USAGE OF COMMAND",
Aliases: []string{"T"},
Action: action,
Flags: flags(),
Category: "CATEGORY",
Subcommands: subcommands(),
}
}
func template(*cli.Context) error {
func action(c *cli.Context) error {
fmt.Println("TEMPLATE RESPONSE")
return nil
}
func flags() []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "test",
Aliases: []string{"t"},
},
}
}
func subcommands() []*cli.Command {
return []*cli.Command{
{
Name: "NAME",
Usage: "USAGE OF COMMAND",
Aliases: []string{"T"},
Action: action,
Flags: flags(),
Category: "CATEGORY",
},
}
}

14
main.go
View File

@ -9,11 +9,19 @@ import (
func main() {
app := &cli.App{
Name: "KleinCommand",
Usage: "manage your home server",
UsageText: "kleinCommand [category] [command] [arguments...]",
Name: "KleinCommand",
Usage: "manage your home server",
UsageText: "kleinCommand [category] [command] [arguments...]",
Version: "v0.0.1",
Authors: []*cli.Author{
{
Name: "Darius",
Email: "darius.klein@dariusklein.nl",
},
},
DefaultCommand: "help",
Commands: []*cli.Command{
commands.Template(),
commands.Welcome(),
commands.Boom(),
commands.BubbleTeaTest(),