Remove cmd directory and add comment to go.mod
This commit is contained in:
parent
e061bcb881
commit
0518fee98e
53
cmd/test.go
53
cmd/test.go
|
@ -1,53 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.fifitido.net/cmd"
|
|
||||||
"go.fifitido.net/cmd/opts"
|
|
||||||
)
|
|
||||||
|
|
||||||
var stringOpt = opts.String("string", "s", "", "example string option")
|
|
||||||
var intOpt = opts.Int("int", "i", 0, "example int option")
|
|
||||||
var boolOpt = opts.Bool("bool", "b", false, "example bool option")
|
|
||||||
var floatOpt = opts.Float("float", "f", 0, "example float option")
|
|
||||||
|
|
||||||
var root = cmd.NewRoot(
|
|
||||||
cmd.WithShortDescription("Example command"),
|
|
||||||
cmd.WithLongDescription(`An example command to show how to use go.fifitido.net/cmd
|
|
||||||
|
|
||||||
this example is just a simple hello world program to show
|
|
||||||
the basics of the library.`),
|
|
||||||
cmd.WithSubcommand(subcmd),
|
|
||||||
cmd.WithArgument("name", false),
|
|
||||||
cmd.WithOptions(stringOpt, intOpt, boolOpt, floatOpt),
|
|
||||||
cmd.WithRunFunc(func(args []string) {
|
|
||||||
if len(args) == 0 {
|
|
||||||
fmt.Println("Hello World!")
|
|
||||||
} else {
|
|
||||||
fmt.Printf("Hello %s!\n", args[0])
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
|
|
||||||
var subcmd = cmd.New(
|
|
||||||
"test",
|
|
||||||
cmd.WithShortDescription("Example command"),
|
|
||||||
cmd.WithLongDescription(`An example command to show how to use go.fifitido.net/cmd
|
|
||||||
|
|
||||||
this example is just a simple hello world program to show
|
|
||||||
the basics of the library.`),
|
|
||||||
cmd.WithArgument("name", false),
|
|
||||||
cmd.WithRunFunc(func(args []string) {
|
|
||||||
if len(args) == 0 {
|
|
||||||
fmt.Println("Hello World!")
|
|
||||||
} else {
|
|
||||||
fmt.Printf("Hello %s!\n", args[0])
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
root.Execute(os.Args)
|
|
||||||
}
|
|
Loading…
Reference in New Issue