mirror of
https://github.com/kemko/xc.git
synced 2026-01-01 15:55:43 +03:00
version
This commit is contained in:
@@ -8,6 +8,6 @@ jobs:
|
|||||||
- checkout
|
- checkout
|
||||||
- run:
|
- run:
|
||||||
name: Building XC
|
name: Building XC
|
||||||
command: go build -o xc cmd/xc/main.go
|
command: ./build.sh
|
||||||
- store_artifacts:
|
- store_artifacts:
|
||||||
path: /tmp/build/xc
|
path: /tmp/build/xc
|
||||||
|
|||||||
14
build.sh
Executable file
14
build.sh
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
kname=`uname -s`
|
||||||
|
kver=`uname -r`
|
||||||
|
karch=`uname -m`
|
||||||
|
gitcommit=`git rev-list --tags --max-count=1`
|
||||||
|
appver=`git describe --tags $gitcommit`
|
||||||
|
appbuild=`git rev-list ${appver}.. --count`
|
||||||
|
|
||||||
|
importroot="github.com/viert/xc/cli"
|
||||||
|
|
||||||
|
go build -o xc \
|
||||||
|
-ldflags="-X $importroot.appVersion=$appver -X $importroot.appBuild=$appbuild -X $importroot.kernelName=$kname -X $importroot.kernelVersion=$kver -X $importroot.kernelArch=$karch" \
|
||||||
|
cmd/xc/main.go
|
||||||
@@ -50,6 +50,7 @@ func (c *Cli) setupCmdHandlers() {
|
|||||||
c.handlers["use_password_manager"] = c.doUsePasswordManager
|
c.handlers["use_password_manager"] = c.doUsePasswordManager
|
||||||
c.handlers["distribute_type"] = c.doDistributeType
|
c.handlers["distribute_type"] = c.doDistributeType
|
||||||
c.handlers["_passmgr_debug"] = c.doPassmgrDebug
|
c.handlers["_passmgr_debug"] = c.doPassmgrDebug
|
||||||
|
c.handlers["version"] = c.doVersion
|
||||||
|
|
||||||
commands := make([]string, len(c.handlers))
|
commands := make([]string, len(c.handlers))
|
||||||
i := 0
|
i := 0
|
||||||
@@ -60,6 +61,10 @@ func (c *Cli) setupCmdHandlers() {
|
|||||||
c.completer = newCompleter(c.store, commands)
|
c.completer = newCompleter(c.store, commands)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Cli) doVersion(name string, argsLine string, args ...string) {
|
||||||
|
term.Successf("XC version %s\n", version())
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Cli) doExit(name string, argsLine string, args ...string) {
|
func (c *Cli) doExit(name string, argsLine string, args ...string) {
|
||||||
c.stopped = true
|
c.stopped = true
|
||||||
}
|
}
|
||||||
|
|||||||
19
cli/version.go
Normal file
19
cli/version.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package cli
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
var (
|
||||||
|
appVersion = ""
|
||||||
|
appBuild = ""
|
||||||
|
|
||||||
|
kernelName = ""
|
||||||
|
kernelVersion = ""
|
||||||
|
kernelArch = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
func version() string {
|
||||||
|
if appVersion == "" {
|
||||||
|
return "dev"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s-%s (%s %s %s)", appVersion, appBuild, kernelName, kernelVersion, kernelArch)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user