- 必要引數 Required Parameters
- 型別標誌和選項解析 Typed Flag/Option Parsing
- 標誌別名 Flag Aliasing
- 子命令 DSL 用於建立完整的 CLI 應用
package main import ( "fmt" "github.com/jwaldrip/odin/cli" ) // CLI is the odin CLI var CLI = NewCLI("0.0.1", "my cli", func(c cli.Command){ if c.Flag("gopher").Get() == true { fmt.Println("IT IS JUST GOPHERTASTIC!!!") } else { fmt.Println("It is just fine") } }) func init(){ CLI.DefineBoolFlag("gopher", false, "is it gophertastic?") CLI.FlagAlias('g', "gopher") } func main(){ CLI.Start() }
來自:開源中國
相關閱讀
評論(1)