本文整理汇总了Golang中gopkg/in/alecthomas/kingpin/v2.Application类的典型用法代码示例。如果您正苦于以下问题:Golang Application类的具体用法?Golang Application怎么用?Golang Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Application类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: sanitizeMessage
func sanitizeMessage(app *kp.Application, message string) string {
reg := regexp.MustCompile("(?m)^#.*$")
stripped := reg.ReplaceAllString(message, "")
content := strings.TrimSpace(stripped)
if len(content) == 0 {
app.FatalIfError(errors.New(noMessageProvided), "io")
}
return content
}
示例2: contentsOfFile
func contentsOfFile(app *kp.Application, filePath string) []byte {
content, err := ioutil.ReadFile(filePath)
if err != nil {
if app != nil {
app.FatalIfError(err, "io")
} else {
return []byte{}
}
}
return []byte(content)
}
示例3: getMessageFromEditor
func getMessageFromEditor(app *kp.Application, repoPath string) string {
editor := gg.ConfiguredEditor(repoPath)
file, err := ioutil.TempFile("", "gitc")
app.FatalIfError(err, "io")
path := file.Name()
file.Write(commentTemplateText(app, repoPath))
file.Close()
err = gx.ExecCommand(editor, path)
app.FatalIfError(err, "io")
content, err := ioutil.ReadFile(path)
os.Remove(path)
app.FatalIfError(err, "io")
return sanitizeMessage(app, string(content))
}
示例4: fatalIfError
// Return the success value, otherwise kill the app with
// the error code specified
func fatalIfError(app *kp.Application, r result.Result, code string) interface{} {
app.FatalIfError(r.Failure, code)
return r.Success
}
示例5: configure
func (sc *serverCommand) configure(app *kingpin.Application) {
cmd := app.Command("server", "run rss2go web server").Action(sc.run)
cmd.Flag("port", "port to listen on").Default("7999").OverrideDefaultFromEnvar("PORT").Int32Var(&sc.Port)
}