improve gcmd with arguments parser

This commit is contained in:
John
2019-09-05 11:38:36 +08:00
parent ad43989944
commit 6cf4bf81e5
31 changed files with 814 additions and 604 deletions

View File

@ -1,22 +0,0 @@
package main
import (
"fmt"
"github.com/gogf/gf/os/gcmd"
)
func doEcho() {
fmt.Println("do echo")
}
func main() {
fmt.Println(gcmd.Value.GetAll())
fmt.Println(gcmd.Value.Get(1))
gcmd.BindHandle("echo", doEcho)
gcmd.RunHandle("echo")
gcmd.AutoRun()
}

View File

@ -1,21 +0,0 @@
package main
import (
"fmt"
"github.com/gogf/gf/os/gcmd"
)
func help() {
fmt.Println("This is help.")
}
func test() {
fmt.Println("This is test.")
}
func main() {
gcmd.BindHandle("help", help)
gcmd.BindHandle("test", test)
gcmd.AutoRun()
}

View File

@ -1,11 +1,13 @@
package main
import (
"fmt"
"github.com/gogf/gf/os/gfile"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/text/gregex"
)
func main() {
fmt.Println(gfile.TempDir())
s := `-abc`
m, err := gregex.MatchString(`^\-{1,2}a={0,1}(.*)`, s)
g.Dump(err)
g.Dump(m)
}