[lxc-devel] [distrobuilder/master] Add version
monstermunchkin on Github
lxc-bot at linuxcontainers.org
Mon Oct 14 09:09:30 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20191014/3a2da9aa/attachment.bin>
-------------- next part --------------
From 5e911f01bfb934a348863576503d9f7c61e68408 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Mon, 14 Oct 2019 11:08:22 +0200
Subject: [PATCH] Add version
Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
distrobuilder/main.go | 7 +++++++
shared/version/version.go | 4 ++++
2 files changed, 11 insertions(+)
create mode 100644 shared/version/version.go
diff --git a/distrobuilder/main.go b/distrobuilder/main.go
index 3594339..0142f58 100644
--- a/distrobuilder/main.go
+++ b/distrobuilder/main.go
@@ -68,6 +68,7 @@ import (
"gopkg.in/yaml.v2"
"github.com/lxc/distrobuilder/shared"
+ "github.com/lxc/distrobuilder/shared/version"
"github.com/lxc/distrobuilder/sources"
)
@@ -76,6 +77,7 @@ type cmdGlobal struct {
flagCacheDir string
flagOptions []string
flagTimeout uint
+ flagVersion bool
definition *shared.Definition
sourceDir string
@@ -119,6 +121,11 @@ func main() {
[]string{}, "Override options (list of key=value)"+"``")
app.PersistentFlags().UintVarP(&globalCmd.flagTimeout, "timeout", "t", 0,
"Timeout in seconds"+"``")
+ app.PersistentFlags().BoolVar(&globalCmd.flagVersion, "version", false, "Print version number")
+
+ // Version handling
+ app.SetVersionTemplate("{{.Version}}\n")
+ app.Version = version.Version
// LXC sub-commands
LXCCmd := cmdLXC{global: &globalCmd}
diff --git a/shared/version/version.go b/shared/version/version.go
new file mode 100644
index 0000000..47b68d7
--- /dev/null
+++ b/shared/version/version.go
@@ -0,0 +1,4 @@
+package version
+
+// Version contains the distrobuilder version number
+var Version = "1.0"
More information about the lxc-devel
mailing list