1 Star 0 Fork 21

eddylapis / Fyne

forked from Gitee 极速下载 / Fyne 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 1.51 KB
一键复制 编辑 原始数据 按行查看 历史
// Run a command line helper for various Fyne tools.
package main
import (
"flag"
"fmt"
"os"
)
var commands map[string]command
var provider command
func printUsage() {
fmt.Println("Usage: fyne [command] [parameters], where command is one of:")
fmt.Print(" ")
i := 0
for id := range commands {
fmt.Print(id)
if i < len(commands)-1 {
fmt.Print(", ")
}
i++
}
fmt.Println(" or help")
fmt.Println()
if provider != nil {
provider.printHelp(" ")
} else {
for id, provider := range commands {
fmt.Printf(" %s\n", id)
provider.printHelp(" ")
fmt.Printf(" For more information run \"fyne help %s\"\n", id)
fmt.Println("")
}
}
flag.PrintDefaults()
}
func help() {
printUsage()
os.Exit(2) // consistent with flag.Parse() with -help
}
func loadCommands() {
commands = make(map[string]command)
commands["bundle"] = &bundler{}
commands["package"] = &packager{}
}
func main() {
loadCommands()
flag.Usage = printUsage
// first let's extract the first "command"
args := os.Args[1:]
if len(args) < 1 {
help()
}
command := args[0]
if command[0] == '-' { // there was a parameter instead of a command
help()
}
if command == "help" {
if len(args) >= 2 {
provider = commands[args[1]]
provider.addFlags()
}
help()
} else {
provider = commands[command]
if provider == nil {
fmt.Fprintln(os.Stderr, "Unsupported command", command)
return
}
provider.addFlags()
// then parse the remaining args
flag.CommandLine.Parse(args[1:])
provider.run(flag.Args())
}
}
Go
1
https://gitee.com/eddylapis/Fyne.git
git@gitee.com:eddylapis/Fyne.git
eddylapis
Fyne
Fyne
v1.0.0

搜索帮助

53164aa7 5694891 3bd8fe86 5694891