File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -5,18 +5,21 @@ ifeq (run,$(firstword $(MAKECMDGOALS)))
5
5
$(eval $(RUN_ARGS ) :;@:)
6
6
endif
7
7
8
+ VERSION := $(shell git tag | grep ^v | sort -V | tail -n 1)
9
+ LDFLAGS = -ldflags "-X main.Version=${VERSION}"
10
+
8
11
.PHONY : help
9
12
10
13
help :
11
14
@grep -E ' ^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | sort | awk ' BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
12
15
13
16
build : # # creates binary
14
- go build .
17
+ go build ${LDFLAGS} .
15
18
install : build # # compiles and installs into system
16
19
sudo cp magento-cli /usr/local/bin/magento
17
20
sudo chmod +x /usr/local/bin/magento
18
21
run : # # run the command through go, accepts args i.e. `make run -- build -h`
19
- go run ./main.go $(RUN_ARGS )
22
+ go run ${LDFLAGS} ./main.go $(RUN_ARGS )
20
23
test : build
21
24
go test --cover ./...
22
25
coverage : build # # run test suite suitable for codecov.io
Original file line number Diff line number Diff line change @@ -35,7 +35,19 @@ var testMode = false
35
35
36
36
var tempDir string = "./" + configDir + "/tmp"
37
37
38
+ var Version string = ""
39
+
38
40
func main () {
41
+
42
+ // output version info
43
+ if len (os .Args ) > 1 {
44
+ arg := os .Args [1 ]
45
+ if arg == "version" {
46
+ fmt .Println ("Magento CLI by Blue Acorn iCi x Infosys " + Version )
47
+ os .Exit (0 )
48
+ }
49
+ }
50
+
39
51
// put services files in a temp directory
40
52
extractYamlToTemp (services )
41
53
You can’t perform that action at this time.
0 commit comments