Skip to content

Commit e94aa51

Browse files
committed
Show version in help. Close #10
1 parent 16640aa commit e94aa51

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
VERSION=$(shell git describe --tags)
2+
3+
build:
4+
go build -ldflags "-X main.version=$(VERSION)"
5+
6+
install:
7+
go install -ldflags "-X main.version=$(VERSION)"

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ Installation
1212
------------
1313

1414
```sh
15-
go get github.com/pocke/lemonade
15+
go get -d github.com/pocke/lemonade
16+
cd $GOPATH/src/github.com/pocke/lemonade/
17+
make install
1618
```
1719

1820
Or download from [latest release](https://github.com/pocke/lemonade/releases/latest)

main.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
package main
22

3-
import "os"
3+
import (
4+
"fmt"
5+
"os"
6+
)
47

5-
const Usage = `Usage: lemonade [options]... SUB_COMMAND [arg]
8+
var version string
9+
var Usage = fmt.Sprintf(`Usage: lemonade [options]... SUB_COMMAND [arg]
610
Sub Commands:
711
open [URL] Open URL by browser
812
copy [text] Copy text.
@@ -16,7 +20,10 @@ Options:
1620
--trans-loopback=true Translate loopback address [open subcommand only]
1721
--trans-localfile=true Translate local file path [open subcommand only]
1822
--help Show this message
19-
`
23+
24+
25+
Version:
26+
%s`, version)
2027

2128
func main() {
2229
cli := &CLI{

0 commit comments

Comments
 (0)