mirror of
https://github.com/distribution/distribution
synced 2024-11-06 19:35:52 +01:00
Move version printing to version package
Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
8f70e298bf
commit
b75455d2bd
@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
@ -34,7 +33,7 @@ func main() {
|
||||
flag.Parse()
|
||||
|
||||
if showVersion {
|
||||
printVersion(os.Stdout)
|
||||
version.PrintVersion()
|
||||
return
|
||||
}
|
||||
|
||||
@ -59,10 +58,6 @@ func usage() {
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
func printVersion(w io.Writer) {
|
||||
fmt.Fprintln(w, os.Args[0], version.Package, version.Version)
|
||||
}
|
||||
|
||||
func fatalf(format string, args ...interface{}) {
|
||||
fmt.Fprintf(os.Stderr, format+"\n", args...)
|
||||
usage()
|
||||
|
26
version/print.go
Normal file
26
version/print.go
Normal file
@ -0,0 +1,26 @@
|
||||
package version
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
// FprintVersion outputs the version string to the writer, in the following
|
||||
// format, followed by a newline:
|
||||
//
|
||||
// <cmd> <project> <version>
|
||||
//
|
||||
// For example, a binary "registry" built from github.com/docker/distribution
|
||||
// with version "v2.0" would print the following:
|
||||
//
|
||||
// registry github.com/docker/distribution v2.0
|
||||
//
|
||||
func FprintVersion(w io.Writer) {
|
||||
fmt.Fprintln(w, os.Args[0], Package, Version)
|
||||
}
|
||||
|
||||
// PrintVersion outputs the version information, from Fprint, to stdout.
|
||||
func PrintVersion() {
|
||||
FprintVersion(os.Stdout)
|
||||
}
|
Loading…
Reference in New Issue
Block a user