當前位置: 首頁>>代碼示例>>Golang>>正文


Golang cli.BasicHelpFunc函數代碼示例

本文整理匯總了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

}
開發者ID:sabzil,項目名稱:baggage,代碼行數:26,代碼來源:main.go

示例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)
}
開發者ID:cskksc,項目名稱:sr6,代碼行數:26,代碼來源:main.go

示例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

}
開發者ID:grubernaut,項目名稱:consul-snapshot,代碼行數:31,代碼來源:main.go

示例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)
}
開發者ID:johnt337,項目名稱:cloudconfig,代碼行數:27,代碼來源:main.go

示例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
}
開發者ID:ranjib,項目名稱:Gypsy,代碼行數:26,代碼來源:main.go

示例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
}
開發者ID:ciarant,項目名稱:gcli,代碼行數:34,代碼來源:cli.go

示例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)
}
開發者ID:ketzacoatl,項目名稱:consulacl,代碼行數:29,代碼來源:main.go

示例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
}
開發者ID:srhopkins,項目名稱:aion,代碼行數:25,代碼來源:main.go

示例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
}
開發者ID:yonglehou,項目名稱:spark-6,代碼行數:31,代碼來源:main.go

示例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)
}
開發者ID:Hi-Rube,項目名稱:spore,代碼行數:31,代碼來源:main.go

示例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
}
開發者ID:askagirl,項目名稱:consul,代碼行數:30,代碼來源:main.go

示例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
}
開發者ID:kosmikko,項目名稱:go-areena-dl,代碼行數:29,代碼來源:cli.go

示例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
}
開發者ID:FihlaTV,項目名稱:bridge-server,代碼行數:31,代碼來源:main.go

示例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)
}
開發者ID:oldmantaiter,項目名稱:dkron,代碼行數:55,代碼來源:main.go

示例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
}
開發者ID:mbrodala,項目名稱:otto,代碼行數:47,代碼來源:main.go


注:本文中的github.com/mitchellh/cli.BasicHelpFunc函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。