X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/cc952178056bf6d29471f6986306fb673dcf394a..ef48a49d302ca25136bbb2ed96319a8b56b46250:/lib/cmd/cmd.go diff --git a/lib/cmd/cmd.go b/lib/cmd/cmd.go index 9292ef7e5f..24b69f0cc5 100644 --- a/lib/cmd/cmd.go +++ b/lib/cmd/cmd.go @@ -28,11 +28,18 @@ func (f HandlerFunc) RunCommand(prog string, args []string, stdin io.Reader, std return f(prog, args, stdin, stdout, stderr) } -type Version string +// Version is a Handler that prints the package version (set at build +// time using -ldflags) and Go runtime version to stdout, and returns +// 0. +var Version versionCommand -func (v Version) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int { +var version = "dev" + +type versionCommand struct{} + +func (versionCommand) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int { prog = regexp.MustCompile(` -*version$`).ReplaceAllLiteralString(prog, "") - fmt.Fprintf(stdout, "%s %s (%s)\n", prog, v, runtime.Version()) + fmt.Fprintf(stdout, "%s %s (%s)\n", prog, version, runtime.Version()) return 0 }