Skip to content

Commit 2d86734

Browse files
committed
add version option
1 parent 0b3ec75 commit 2d86734

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

.goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ builds:
1616
- 386
1717
main: ./cmd/aces
1818
ldflags:
19-
- -s -w
19+
- -s -w -X main.version=v{{.Version}} # -X main.commit={{.Commit}} -X main.date={{.Date}}
2020
ignore: # problems with build
2121
- goos: windows
2222
goarch: arm64

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ Head over to [releases](https://github.com/quackduck/aces/releases) and download
6565
Aces - Encode in any character set
6666

6767
Usage:
68-
aces <charset> - encode data from STDIN into <charset>
69-
aces -d/--decode <charset> - decode data from STDIN from <charset>
70-
aces -h/--help - print this help message
68+
aces <charset> - encode data from STDIN into <charset>
69+
aces -d/--decode <charset> - decode data from STDIN from <charset>
70+
aces -v/--version | -h/--help - print version or this help message
7171

7272
Aces reads from STDIN for your data and outputs the result to STDOUT. An optimized algorithm is used
7373
for character sets with a power of 2 length. Newlines are ignored when decoding.

cmd/aces/main.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ var (
1212
helpMsg = `Aces - Encode in any character set
1313
1414
Usage:
15-
aces <charset> - encode data from STDIN into <charset>
16-
aces -d/--decode <charset> - decode data from STDIN from <charset>
17-
aces -h/--help - print this help message
15+
aces <charset> - encode data from STDIN into <charset>
16+
aces -d/--decode <charset> - decode data from STDIN from <charset>
17+
aces -v/--version | -h/--help - print version or this help message
1818
1919
Aces reads from STDIN for your data and outputs the result to STDOUT. An optimized algorithm is used
2020
for character sets with a power of 2 length. Newlines are ignored when decoding.
@@ -31,6 +31,7 @@ Examples:
3131
Set the encoding/decoding buffer size with --bufsize <size> (default 16KiB).
3232
3333
File issues, contribute or star at github.com/quackduck/aces`
34+
version = "dev"
3435
)
3536

3637
func main() {
@@ -60,6 +61,12 @@ func main() {
6061
fmt.Println(helpMsg)
6162
return
6263
}
64+
65+
if os.Args[1] == "-v" || os.Args[1] == "--version" {
66+
fmt.Println("Aces " + version)
67+
return
68+
}
69+
6370
decode := os.Args[1] == "--decode" || os.Args[1] == "-d"
6471
if decode {
6572
if len(os.Args) == 2 {

0 commit comments

Comments
 (0)