Skip to content

Commit 48362d6

Browse files
committed
note version
1 parent 6f0c297 commit 48362d6

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ go.work.sum
2525
.env
2626

2727
note
28+
build/

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
.PHONY: build-amd64
2+
3+
module := github.com/bdazl/note
4+
release_version := $(shell git describe --tag)
5+
16
install-prereq:
27
# https://github.com/mattn/go-sqlite3?tab=readme-ov-file#installation
38
CGO_ENABLED=1 go install github.com/mattn/go-sqlite3
9+
10+
build-linux:
11+
mkdir -p build/amd64/linux
12+
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags="-X '$(module)/cmd.Version=$(release_version)'" -o build/amd64/linux/note

cmd/root.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ Files will only be imported once (per run), no checks for duplicate notes are ma
241241
Short: "Export notes to JSON or YAML file",
242242
Run: noteExport,
243243
}
244+
versionCmd = &cobra.Command{
245+
Use: "version",
246+
Aliases: []string{"ver"},
247+
Short: "Version of this program",
248+
Run: noteVersion,
249+
}
244250

245251
// Global arguments
246252
configPathArg string
@@ -371,6 +377,7 @@ func init() {
371377

372378
rootCmd.AddCommand(
373379
initCmd,
380+
versionCmd,
374381
addCmd, removeCmd,
375382
getCmd, listCmd, tableCmd, idCmd, spaceCmd,
376383
editCmd, pinCmd, unpinCmd, moveCmd,

cmd/version.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Copyright © 2024 Jacob Peyron <[email protected]>
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
THE SOFTWARE.
21+
*/
22+
package cmd
23+
24+
import (
25+
"fmt"
26+
"runtime"
27+
28+
"github.com/spf13/cobra"
29+
)
30+
31+
var Version string = "vx.y.z-dev"
32+
33+
func noteVersion(_ *cobra.Command, _ []string) {
34+
fmt.Printf("note version %v %v/%v\n", Version, runtime.GOOS, runtime.GOARCH)
35+
}

0 commit comments

Comments
 (0)