Skip to content

Commit

Permalink
Add version command
Browse files Browse the repository at this point in the history
  • Loading branch information
TomWright committed Oct 24, 2024
1 parent 9dbe990 commit 48ec95d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**

- OS: [e.g. iOS]
- Version [e.g. 22] (`dasel --version`)
- Version [e.g. 22] (`dasel version`)

**Additional context**
Add any other context about the problem here.
2 changes: 1 addition & 1 deletion .github/workflows/build-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ jobs:
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} CGO_ENABLED=0 go build -o target/release/${{ matrix.artifact_name }} -ldflags="-X 'github.com/tomwright/dasel/v3/internal.Version=${{ env.RELEASE_VERSION }}'" ./cmd/dasel
- name: Test version
if: matrix.test_version == true
run: ./target/release/${{ matrix.artifact_name }} --version
run: ./target/release/${{ matrix.artifact_name }} version
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} CGO_ENABLED=0 go build -o target/release/${{ matrix.artifact_name }} -ldflags="-X 'github.com/tomwright/dasel/v3/internal.Version=${{ env.RELEASE_VERSION }}'" ./cmd/dasel
- name: Test version
if: matrix.test_version == true
run: ./target/release/${{ matrix.artifact_name }} --version
run: ./target/release/${{ matrix.artifact_name }} version
- name: Test execution
if: matrix.test_execution == true
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} CGO_ENABLED=0 go build -o target/release/${{ matrix.artifact_name }} -ldflags="-X 'github.com/tomwright/dasel/v3/internal.Version=${{ env.RELEASE_VERSION }}'" ./cmd/dasel
- name: Test version
if: matrix.test_version == true
run: ./target/release/${{ matrix.artifact_name }} --version
run: ./target/release/${{ matrix.artifact_name }} version
- name: Gzip binaries
run: gzip -c ./target/release/${{ matrix.artifact_name }} > ./target/release/${{ matrix.artifact_name }}.gz
- name: Upload binaries to release
Expand Down
3 changes: 2 additions & 1 deletion internal/cli/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ type Globals struct {
type CLI struct {
Globals

Query QueryCmd `cmd:"" help:"Execute a query"`
Query QueryCmd `cmd:"" help:"Execute a query"`
Version VersionCmd `cmd:"" help:"Print the version"`
}

func MustRun(stdin io.Reader, stdout, stderr io.Writer) {
Expand Down
11 changes: 11 additions & 0 deletions internal/cli/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cli

import "github.com/tomwright/dasel/v3/internal"

type VersionCmd struct {
}

func (c *VersionCmd) Run(ctx *Globals) error {
_, err := ctx.Stdout.Write([]byte(internal.Version + "\n"))
return err
}

0 comments on commit 48ec95d

Please sign in to comment.