Skip to content

Commit 68a030d

Browse files
author
parisb
committed
feat: add version command
1 parent d1d6898 commit 68a030d

File tree

5 files changed

+35
-11
lines changed

5 files changed

+35
-11
lines changed

.github/workflows/release.yaml

Whitespace-only changes.

.goreleaser.yaml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
# This is an example .goreleaser.yml file with some sensible defaults.
2-
# Make sure to check the documentation at https://goreleaser.com
3-
4-
# The lines below are called `modelines`. See `:help modeline`
5-
# Feel free to remove those if you don't want/need to use them.
6-
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
7-
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
8-
91
version: 2
102

113
before:
@@ -22,12 +14,13 @@ builds:
2214
- linux
2315
# - windows
2416
# - darwin
25-
17+
ldflags:
18+
- -s -w -X github.com/OneFineDev/tmpltr/cmd.version={{.Version}}
2619
archives:
2720
- formats: tar.gz
2821
# this name template makes the OS and Arch compatible with the results of `uname`.
2922
name_template: >-
30-
tmpltr_
23+
tmpltr
3124
{{ .Version }}_
3225
{{- title .Os }}_
3326
{{- if eq .Arch "amd64" }}x86_64

cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func NewRootCommand() *cobra.Command {
8888
NewGetCommand(),
8989
NewCreateCommand(),
9090
NewProjectCommand(),
91+
NewVersionCommand(),
9192
)
9293

9394
return rootCmd

cmd/version.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spf13/cobra"
7+
)
8+
9+
var (
10+
version = "dev"
11+
)
12+
13+
func NewVersionCommand() *cobra.Command {
14+
VersionCmd := &cobra.Command{
15+
Use: "version",
16+
Short: "A brief description of your command",
17+
Long: `A longer description that spans multiple lines and likely contains examples
18+
and usage of using your command. For example:
19+
20+
Cobra is a CLI library for Go that empowers applications.
21+
This application is a tool to generate the needed files
22+
to quickly Version a Cobra application.`,
23+
24+
RunE: func(c *cobra.Command, _ []string) error {
25+
_, _ = fmt.Fprintf(c.OutOrStderr(), "%s\n", version)
26+
return nil
27+
},
28+
}
29+
30+
return VersionCmd
31+
}

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ require (
77
github.com/cucumber/godog v0.15.0
88
github.com/go-git/go-billy/v5 v5.6.2
99
github.com/go-git/go-git/v5 v5.16.0
10-
github.com/onsi/gomega v1.34.1
1110
github.com/pkg/errors v0.9.1
1211
github.com/spf13/afero v1.14.0
1312
github.com/spf13/cobra v1.9.1

0 commit comments

Comments
 (0)