mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
improve gcmd with arguments parser
This commit is contained in:
@ -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()
|
||||
}
|
||||
@ -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()
|
||||
}
|
||||
@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user