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


Golang subcommands.Application類代碼示例

本文整理匯總了Golang中github.com/maruel/subcommands.Application的典型用法代碼示例。如果您正苦於以下問題:Golang Application類的具體用法?Golang Application怎麽用?Golang Application使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Application類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Run

func (c *greetRun) Run(a subcommands.Application, args []string, env subcommands.Env) int {
	if len(args) != 1 {
		fmt.Fprintf(os.Stderr, "%s: Can only greet one person at a time.\n", a.GetName())
		return 1
	}
	fmt.Printf("Hi %s!\n", args[0])
	return 0
}
開發者ID:maruel,項目名稱:subcommands,代碼行數:8,代碼來源:main.go

示例2: Run

func (c *versionRun) Run(a subcommands.Application, args []string) int {
	if len(args) != 0 {
		fmt.Fprintf(a.GetErr(), "%s: position arguments not expected\n", a.GetName())
		return 1
	}
	fmt.Println(c.version)
	return 0
}
開發者ID:shishkander,項目名稱:luci-go,代碼行數:8,代碼來源:version.go

示例3: Run

func (c *greetRun) Run(a subcommands.Application, args []string, env subcommands.Env) int {
	if len(args) != 1 {
		fmt.Fprintf(a.GetErr(), "%s: Can only greet one person at a time.\n", a.GetName())
		return 1
	}
	d := a.(SampleApplication)
	if err := c.main(d, args[0], env["GREET_STYLE"].Value); err != nil {
		fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
		return 1
	}
	return 0
}
開發者ID:maruel,項目名稱:subcommands,代碼行數:12,代碼來源:greet.go

示例4: Run

func (c *askBeerRun) Run(a subcommands.Application, args []string, env subcommands.Env) int {
	if len(args) != 0 {
		fmt.Fprintf(a.GetErr(), "%s: Unknown arguments.\n", a.GetName())
		return 1
	}
	d := a.(askApplication)
	if err := c.main(d); err != nil {
		fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
		return 1
	}
	return 0
}
開發者ID:maruel,項目名稱:subcommands,代碼行數:12,代碼來源:ask_beer.go

示例5: Run

func (c *gcRun) Run(a subcommands.Application, args []string) int {
	if len(args) != 0 {
		fmt.Fprintf(a.GetErr(), "%s: Unsupported arguments.\n", a.GetName())
		return 1
	}
	d := a.(DumbcasApplication)
	if err := c.main(d); err != nil {
		fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
		return 1
	}
	return 0
}
開發者ID:maruel,項目名稱:dumbcas,代碼行數:12,代碼來源:gc.go

示例6: Run

func (c *restoreRun) Run(a subcommands.Application, args []string) int {
	if len(args) != 1 {
		fmt.Fprintf(a.GetErr(), "%s: Must only provide a <node>.\n", a.GetName())
		return 1
	}
	interrupt.HandleCtrlC()
	d := a.(DumbcasApplication)
	if err := c.main(d, args[0]); err != nil {
		fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
		return 1
	}
	return 0
}
開發者ID:maruel,項目名稱:dumbcas,代碼行數:13,代碼來源:restore.go

示例7: Run

func (c *sleepRun) Run(a subcommands.Application, args []string, env subcommands.Env) int {
	if len(args) != 0 {
		fmt.Fprintf(a.GetErr(), "%s: Unsupported arguments.\n", a.GetName())
		return 1
	}
	d := a.(SampleApplication)
	// This main() wrapping simplifies the surfacing of errors into printing to
	// stderr then exiting with 1.
	if err := c.main(d, env["VERBOSE_DREAMS"].Value == "1"); err != nil {
		fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
		return 1
	}
	return 0
}
開發者ID:maruel,項目名稱:subcommands,代碼行數:14,代碼來源:sleep.go

示例8: Run

func (c *versionRun) Run(a subcommands.Application, args []string) int {
	if len(args) != 0 {
		fmt.Fprintf(a.GetErr(), "%s: Unsupported arguments.\n", a.GetName())
		return 1
	}
	fmt.Fprintf(a.GetOut(), "0.1\n")
	return 0
}
開發者ID:maruel,項目名稱:dumbcas,代碼行數:8,代碼來源:version.go

示例9: Run

func (c *downloadRun) Run(a subcommands.Application, args []string) int {
	if err := c.Parse(a, args); err != nil {
		fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
		return 1
	}
	cl, err := c.defaultFlags.StartTracing()
	if err != nil {
		fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
		return 1
	}
	defer cl.Close()
	if err := c.main(a, args); err != nil {
		fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
		return 1
	}
	return 0
}
開發者ID:shishkander,項目名稱:luci-go,代碼行數:17,代碼來源:download.go


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