Remove cmd directory and add comment to go.mod

This commit is contained in:
Evan Fiordeliso 2023-11-12 14:28:44 -05:00
parent e061bcb881
commit 0518fee98e
2 changed files with 1 additions and 54 deletions

View File

@ -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)
}

2
go.mod
View File

@ -2,4 +2,4 @@ module go.fifitido.net/cmd
go 1.21.3
require github.com/spf13/pflag v1.0.5
require github.com/spf13/pflag v1.0.5 // Used by opts/benchmarks_test.go