本文整理匯總了Golang中github.com/mitchellh/cli.BasicHelpFunc函數的典型用法代碼示例。如果您正苦於以下問題:Golang BasicHelpFunc函數的具體用法?Golang BasicHelpFunc怎麽用?Golang BasicHelpFunc使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了BasicHelpFunc函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: realMain
func realMain() int {
args := os.Args[1:]
for _, arg := range args {
if arg == "-v" || arg == "--version" {
newArgs := make([]string, len(args)+1)
copy(newArgs[1:], args)
args = newArgs
break
}
}
cli := &cli.CLI{
Args: args,
Commands: Commands,
HelpFunc: cli.BasicHelpFunc("Baggage"),
}
exitCode, err := cli.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
return 1
}
return exitCode
}
示例2: main
func main() {
args := os.Args[1:]
// Get the command line args. We shortcut "--version" and "-v" to
// just show the version.
for _, arg := range args {
if arg == "-v" || arg == "--version" {
newArgs := make([]string, 1)
newArgs[0] = "version"
args = newArgs
break
}
}
cli := &cli.CLI{
Args: args,
Commands: Commands,
HelpFunc: cli.BasicHelpFunc("sr6"),
}
exitCode, err := cli.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
os.Exit(1)
}
os.Exit(exitCode)
}
示例3: realMain
// Just our main function to kick things off in a loop.
func realMain() int {
args := os.Args[1:]
for _, arg := range args {
if arg == "-v" || arg == "-version" || arg == "--version" {
newArgs := make([]string, len(args)+1)
newArgs[0] = "version"
copy(newArgs[1:], args)
args = newArgs
break
}
}
cli := &cli.CLI{
Args: args,
Commands: Commands,
HelpFunc: cli.FilteredHelpFunc(
CommandsInclude, cli.BasicHelpFunc("consul-snapshot")),
HelpWriter: os.Stdout,
}
exitCode, err := cli.Run()
if err != nil {
log.Fatalf("Error executing CLI: %s", err.Error())
return 1
}
return exitCode
}
示例4: main
// main - run our app
func main() {
args := os.Args[1:]
for _, arg := range args {
if arg == "-v" || arg == "--version" {
newArgs := make([]string, len(args)+1)
newArgs[0] = "version"
copy(newArgs[1:], args)
args = newArgs
break
}
}
cli := &cli.CLI{
Args: args,
Commands: Commands,
HelpFunc: cli.BasicHelpFunc("cloudconfig"),
}
exitCode, err := cli.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
}
os.Exit(exitCode)
}
示例5: realMain
func realMain(args []string, commands map[string]cli.CommandFactory) int {
for _, arg := range args {
if arg == "-v" || arg == "-version" || arg == "--version" {
newArgs := make([]string, len(args)+1)
newArgs[0] = "version"
copy(newArgs[1:], args)
args = newArgs
break
}
}
cmdNames := make([]string, 0, len(commands))
for cmdName := range commands {
cmdNames = append(cmdNames, cmdName)
}
cli := &cli.CLI{
Args: args,
Commands: commands,
HelpFunc: cli.FilteredHelpFunc(cmdNames, cli.BasicHelpFunc("gypsy")),
}
exitCode, err := cli.Run()
if err != nil {
log.Warnf("Error executing CLI: %s", err.Error())
return 1
}
return exitCode
}
示例6: RunCustom
// RunCustom execute mitchellh/cli and return its exit code.
func RunCustom(args []string, commands map[string]cli.CommandFactory) int {
for _, arg := range args {
// If the following options are provided,
// then execute gcli version command
if arg == "-v" || arg == "-version" || arg == "--version" {
args[1] = "version"
break
}
// Generating godoc (doc.go). This is only for gcli developper.
if arg == "-godoc" {
return runGodoc(commands)
}
}
cli := &cli.CLI{
Args: args[1:],
Commands: commands,
Version: Version,
HelpFunc: cli.BasicHelpFunc(Name),
HelpWriter: os.Stdout,
}
exitCode, err := cli.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to execute: %s\n", err.Error())
}
return exitCode
}
示例7: main
func main() {
log.SetOutput(ioutil.Discard)
args := os.Args[1:]
for _, arg := range args {
if arg == "--" {
break
}
if arg == "-v" || arg == "--version" {
fmt.Printf("%s v%s\n", Name, Version)
os.Exit(0)
}
}
cli := &cli.CLI{
Args: args,
Commands: Commands,
HelpFunc: cli.BasicHelpFunc("consulacl"),
}
exitCode, err := cli.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
os.Exit(1)
}
os.Exit(exitCode)
}
示例8: run
func run() (int, error) {
conf, err := config.Load()
if err != nil {
log.Fatalln(err)
}
c := &cli.CLI{
Name: aionName,
Version: aionVersion,
Args: os.Args[1:],
HelpFunc: cli.BasicHelpFunc(aionName),
Commands: map[string]cli.CommandFactory{
"show": command.NewShow(conf),
"version": command.NewVersion(aionVersion),
},
}
retval, err := c.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
return 1, err
}
return retval, nil
}
示例9: realMain
func realMain() int {
args := os.Args[1:]
// Get the command line args. We shortcut "--version" and "-v" to
// just show the version.
// Copied from https://github.com/hashicorp/consul/blob/master/main.go
for _, arg := range args {
if arg == "-v" || arg == "--version" {
newArgs := make([]string, len(args)+1)
newArgs[0] = "version"
copy(newArgs[1:], args)
args = newArgs
break
}
}
cli := &cli.CLI{
Args: args,
Commands: Commands,
HelpFunc: cli.BasicHelpFunc("spark"),
}
exitCode, err := cli.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
return 1
}
return exitCode
}
示例10: main
func main() {
ui = &cli.BasicUi{Writer: os.Stdout}
app := &cli.CLI{
HelpFunc: cli.BasicHelpFunc("spored"),
Args: os.Args[1:],
Version: env.VERSION,
Commands: map[string]cli.CommandFactory{
"crawl": func() (cli.Command, error) {
return &command.CrawlCommand{ui}, nil
},
"serve": func() (cli.Command, error) {
return &command.ServeCommand{ui}, nil
},
"stat": func() (cli.Command, error) {
return &command.StatCommand{ui}, nil
},
"total": func() (cli.Command, error) {
return &command.TotalCommand{ui}, nil
},
},
}
exitCode, err := app.Run()
if err != nil {
log.Println(err)
}
os.Exit(exitCode)
}
示例11: realMain
func realMain() int {
log.SetOutput(ioutil.Discard)
// Get the command line args. We shortcut "--version" and "-v" to
// just show the version.
args := os.Args[1:]
for _, arg := range args {
if arg == "-v" || arg == "--version" {
newArgs := make([]string, len(args)+1)
newArgs[0] = "version"
copy(newArgs[1:], args)
args = newArgs
break
}
}
cli := &cli.CLI{
Args: args,
Commands: Commands,
HelpFunc: cli.BasicHelpFunc("consul"),
}
exitCode, err := cli.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
return 1
}
return exitCode
}
示例12: RunCustom
func RunCustom(args []string, commands map[string]cli.CommandFactory) int {
// Get the command line args. We shortcut "--version" and "-v" to
// just show the version.
for _, arg := range args {
if arg == "-v" || arg == "-version" || arg == "--version" {
newArgs := make([]string, len(args)+1)
newArgs[0] = "version"
copy(newArgs[1:], args)
args = newArgs
break
}
}
cli := &cli.CLI{
Args: args,
Commands: commands,
Version: Version,
HelpFunc: cli.BasicHelpFunc(Name),
HelpWriter: os.Stdout,
}
exitCode, err := cli.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to execute: %s\n", err.Error())
}
return exitCode
}
示例13: realMain
func realMain() int {
ui = &cli.BasicUi{Writer: os.Stdout}
cli := &cli.CLI{
Args: os.Args[1:],
Commands: map[string]cli.CommandFactory{
"up": func() (cli.Command, error) {
return &UpCommand{}, nil
},
"down": func() (cli.Command, error) {
return &DownCommand{}, nil
},
"redo": func() (cli.Command, error) {
return &RedoCommand{}, nil
},
"status": func() (cli.Command, error) {
return &StatusCommand{}, nil
},
},
HelpFunc: cli.BasicHelpFunc("sql-migrate"),
Version: "1.0.0",
}
exitCode, err := cli.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
return 1
}
return exitCode
}
示例14: main
func main() {
// Get the command line args. We shortcut "--version" and "-v" to
// just show the version.
args := os.Args[1:]
for _, arg := range args {
if arg == "-v" || arg == "--version" {
newArgs := make([]string, len(args)+1)
newArgs[0] = "version"
copy(newArgs[1:], args)
args = newArgs
break
}
}
c := cli.NewCLI("dkron", VERSION)
c.Args = args
c.HelpFunc = cli.BasicHelpFunc("dkron")
ui := &cli.BasicUi{Writer: os.Stdout}
plugins := &Plugins{}
plugins.DiscoverPlugins()
// Make sure we clean up any managed plugins at the end of this
defer plugin.CleanupClients()
c.Commands = map[string]cli.CommandFactory{
"agent": func() (cli.Command, error) {
return &dkron.AgentCommand{
Ui: ui,
Version: VERSION,
ProcessorPlugins: plugins.Processors,
}, nil
},
"keygen": func() (cli.Command, error) {
return &dkron.KeygenCommand{
Ui: ui,
}, nil
},
"version": func() (cli.Command, error) {
return &dkron.VersionCommand{
Version: VERSION,
Ui: ui,
}, nil
},
}
exitStatus, err := c.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
os.Exit(1)
}
os.Exit(exitStatus)
}
示例15: wrappedMain
func wrappedMain() int {
// Make sure we cleanup any plugins that were launched.
defer plugin.CleanupClients()
log.SetOutput(os.Stderr)
log.Printf(
"[INFO] Otto version: %s %s %s",
Version, VersionPrerelease, GitCommit)
// Setup signal handlers
initSignalHandlers()
// Load the configuration
config := BuiltinConfig
// Run checkpoint
go runCheckpoint(&config)
// Get the command line args. We shortcut "--version" and "-v" to
// just show the version.
args := os.Args[1:]
for _, arg := range args {
if arg == "-v" || arg == "-version" || arg == "--version" {
newArgs := make([]string, len(args)+1)
newArgs[0] = "version"
copy(newArgs[1:], args)
args = newArgs
break
}
}
cli := &cli.CLI{
Args: args,
Commands: Commands,
HelpFunc: cli.FilteredHelpFunc(
CommandsInclude, cli.BasicHelpFunc("otto")),
HelpWriter: os.Stdout,
}
exitCode, err := cli.Run()
if err != nil {
Ui.Error(fmt.Sprintf("Error executing CLI: %s", err.Error()))
return 1
}
return exitCode
}