2022-06-16 09:02:24 +03:00
|
|
|
package main
|
|
|
|
|
2023-10-23 14:30:51 +03:00
|
|
|
import (
|
2023-11-09 23:44:57 +03:00
|
|
|
"github.com/omnipunk/cli/mtool"
|
2022-06-16 09:02:24 +03:00
|
|
|
"strconv"
|
|
|
|
"fmt"
|
2023-11-09 23:44:57 +03:00
|
|
|
"os"
|
2022-06-16 09:02:24 +03:00
|
|
|
)
|
|
|
|
|
2023-10-23 14:30:51 +03:00
|
|
|
var (
|
2023-11-09 23:44:57 +03:00
|
|
|
root = mtool.T("test").Subs(
|
|
|
|
mtool.T("echo").Func(func(flags *mtool.Flags) {
|
2023-03-23 12:32:52 +03:00
|
|
|
var b bool
|
|
|
|
flags.BoolVar(&b, "b", false, "the check flag")
|
2023-11-09 23:44:57 +03:00
|
|
|
args := flags.Parse()
|
2023-03-24 10:33:13 +03:00
|
|
|
fmt.Println(args)
|
2023-11-09 23:44:57 +03:00
|
|
|
}).Desc(
|
|
|
|
"print string to standard output string",
|
|
|
|
).Usage(
|
|
|
|
"[str1 str2 ... strN]",
|
|
|
|
),
|
|
|
|
mtool.T("sum").Func(func(flags *mtool.Flags) {
|
2023-03-24 10:33:13 +03:00
|
|
|
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)
|
2023-11-09 23:44:57 +03:00
|
|
|
}).Desc(
|
|
|
|
"add one value to another",
|
|
|
|
).Usage(
|
|
|
|
"<int1> <int2>",
|
|
|
|
),
|
|
|
|
mtool.T("sub").Subs(
|
|
|
|
mtool.T("first").Func(func(flags *mtool.Flags) {
|
|
|
|
fmt.Println("called the first", flags.Parse())
|
|
|
|
}).Desc(
|
|
|
|
"description",
|
|
|
|
).Usage(
|
|
|
|
"[nothing here]",
|
|
|
|
),
|
|
|
|
mtool.T("second").Func(func(flags *mtool.Flags){
|
|
|
|
fmt.Println("called the second", flags.Parse())
|
|
|
|
}).Desc(
|
|
|
|
"description",
|
|
|
|
).Usage(
|
|
|
|
"[nothing here]",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
2022-06-16 09:02:24 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2023-11-09 23:44:57 +03:00
|
|
|
root.Run(os.Args[1:])
|
2022-06-16 09:02:24 +03:00
|
|
|
}
|