add version info to the binary

This commit is contained in:
2021-08-24 07:02:12 +03:00
parent be668f21e8
commit 6dd7678e64
3 changed files with 30 additions and 22 deletions

13
main.go
View File

@@ -11,6 +11,9 @@ import (
"git.sr.ht/~motiejus/undocker/rootfs"
)
var Version = "unknown"
var VersionHash = "unknown"
const _usage = `Usage:
%s <infile> <outfile>
@@ -19,13 +22,21 @@ Flatten a Docker container image to a root file system.
Arguments:
<infile>: Input Docker container. Tarball.
<outfile>: Output tarball, the root file system. '-' is stdout.
undocker %s (%s)
Built with %s
`
func main() {
runtime.GOMAXPROCS(1) // no need to create that many threads
if len(os.Args) != 3 {
fmt.Fprintf(os.Stderr, _usage, filepath.Base(os.Args[0]))
fmt.Fprintf(os.Stderr, _usage,
filepath.Base(os.Args[0]),
Version,
VersionHash,
runtime.Version(),
)
os.Exit(1)
}