69 lines
1.7 KiB
Diff
69 lines
1.7 KiB
Diff
From e783a2479de421bd7fef1ef40e200c80ed481fca Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber@ubuntu.com>
|
|
Date: Fri, 30 Mar 2018 11:13:09 -0400
|
|
Subject: lxd/main: Add version subcommand
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
|
|
---
|
|
lxd/main.go | 4 ++++
|
|
lxd/main_version.go | 32 ++++++++++++++++++++++++++++++++
|
|
2 files changed, 36 insertions(+)
|
|
create mode 100644 lxd/main_version.go
|
|
|
|
diff --git a/lxd/main.go b/lxd/main.go
|
|
index 8501dbc6..983f1812 100644
|
|
--- a/lxd/main.go
|
|
+++ b/lxd/main.go
|
|
@@ -147,6 +147,10 @@ func main() {
|
|
sqlCmd := cmdSql{global: &globalCmd}
|
|
app.AddCommand(sqlCmd.Command())
|
|
|
|
+ // version sub-command
|
|
+ versionCmd := cmdVersion{global: &globalCmd}
|
|
+ app.AddCommand(versionCmd.Command())
|
|
+
|
|
// waitready sub-command
|
|
waitreadyCmd := cmdWaitready{global: &globalCmd}
|
|
app.AddCommand(waitreadyCmd.Command())
|
|
diff --git a/lxd/main_version.go b/lxd/main_version.go
|
|
new file mode 100644
|
|
index 00000000..9396b336
|
|
--- /dev/null
|
|
+++ b/lxd/main_version.go
|
|
@@ -0,0 +1,32 @@
|
|
+package main
|
|
+
|
|
+import (
|
|
+ "fmt"
|
|
+
|
|
+ "github.com/spf13/cobra"
|
|
+
|
|
+ cli "github.com/lxc/lxd/shared/cmd"
|
|
+ "github.com/lxc/lxd/shared/version"
|
|
+)
|
|
+
|
|
+type cmdVersion struct {
|
|
+ global *cmdGlobal
|
|
+}
|
|
+
|
|
+func (c *cmdVersion) Command() *cobra.Command {
|
|
+ cmd := &cobra.Command{}
|
|
+ cmd.Use = "version"
|
|
+ cmd.Short = "Show the server version"
|
|
+ cmd.Long = cli.FormatSection("Description",
|
|
+ `Show the server version`)
|
|
+
|
|
+ cmd.RunE = c.Run
|
|
+
|
|
+ return cmd
|
|
+}
|
|
+
|
|
+func (c *cmdVersion) Run(cmd *cobra.Command, args []string) error {
|
|
+ fmt.Println(version.Version)
|
|
+
|
|
+ return nil
|
|
+}
|