1 Star 0 Fork 0

g-golang / fk-deployr

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
cmd_version.go 974 Bytes
一键复制 编辑 原始数据 按行查看 历史
Steve Kemp 提交于 2018-09-06 21:27 . Added version sub-command
//
// Show our version.
//
package main
import (
"context"
"flag"
"fmt"
"runtime"
"github.com/google/subcommands"
)
var (
version = "unreleased"
)
type versionCmd struct {
verbose bool
}
//
// Glue
//
func (*versionCmd) Name() string { return "version" }
func (*versionCmd) Synopsis() string { return "Show our version." }
func (*versionCmd) Usage() string {
return `version :
Report upon our version, and exit.
`
}
//
// Flag setup
//
func (p *versionCmd) SetFlags(f *flag.FlagSet) {
f.BoolVar(&p.verbose, "verbose", false, "Show go version the binary was generated with.")
}
//
// Show the version - using the "out"-writer.
//
func showVersion(verbose bool) {
fmt.Printf("%s\n", version)
if verbose {
fmt.Printf("Built with %s\n", runtime.Version())
}
}
//
// Entry-point.
//
func (p *versionCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
showVersion(p.verbose)
return subcommands.ExitSuccess
}
1
https://gitee.com/g-golang/fk-deployr.git
git@gitee.com:g-golang/fk-deployr.git
g-golang
fk-deployr
fk-deployr
master

搜索帮助