cli/src/cmd/test/main.go

42 lines
702 B
Go
Raw Normal View History

2022-06-16 09:02:24 +03:00
package main
import(
2023-06-26 11:58:47 +03:00
"github.com/mojosa-software/gomtool/src/mtool"
2022-06-16 09:02:24 +03:00
"strconv"
"fmt"
)
var(
2023-03-23 12:32:52 +03:00
tools = mtool.Tools{
"echo" : mtool.Tool{
func(flags *mtool.Flags) {
2023-03-23 12:32:52 +03:00
var b bool
flags.BoolVar(&b, "b", false, "the check flag")
flags.Parse()
args := flags.Args()
fmt.Println(args)
2022-10-11 15:38:48 +03:00
},
"print string to standard output string",
2023-03-23 12:32:52 +03:00
"[str1 str2 ... strN]",
2022-06-16 09:02:24 +03:00
},
2023-03-23 12:32:52 +03:00
"sum" : mtool.Tool{
func(flags *mtool.Flags) {
flags.Parse()
args := flags.Args()
2022-10-11 15:38:48 +03:00
one, _ := strconv.Atoi(args[1])
two, _ := strconv.Atoi(args[2])
fmt.Println(one + two)
},
"add one value to another",
2023-03-23 12:32:52 +03:00
"<int1> <int2>",
2022-06-16 09:02:24 +03:00
},
}
)
func main() {
2023-03-23 12:32:52 +03:00
mtool.Main("test", tools)
2022-06-16 09:02:24 +03:00
}