Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version flag #385

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ builds:
- amd64
- arm
- arm64
- "386"
- '386'
goos:
- darwin
- linux
Expand All @@ -22,17 +22,18 @@ builds:
- openbsd
ignore:
- goos: darwin
goarch: "386"
goarch: '386'
- goos: openbsd
goarch: arm
flags:
- -trimpath
ldflags:
- -s
- -w
- -X github.com/justjanne/powerline-go/powerline.Version={{ .Version }}

archives:
- name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
- name_template: '{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}'
format: binary

checksum:
Expand Down
5 changes: 5 additions & 0 deletions args.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type arguments struct {
IgnoreWarnings *bool
Time *string
ViMode *string
Version *bool
}

var args = arguments{
Expand Down Expand Up @@ -226,4 +227,8 @@ var args = arguments{
"vi-mode",
defaults.ViMode,
comments("The current vi-mode (eg. KEYMAP for zsh) for vi-module module")),
Version: flag.Bool(
"version",
false,
comments("Print the current version and exit")),
}
2 changes: 1 addition & 1 deletion defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ var defaults = Config{
EvalPromptRightSuffix: `"`,
},
"bare": {
ColorTemplate: "%s",
ColorTemplate: "%s",
RootIndicator: "$",
EscapedBackslash: `\`,
EscapedBacktick: "`",
Expand Down
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ func commentsWithDefaults(lines ...string) string {
func main() {
flag.Parse()

if *args.Version {
fmt.Println(pwl.Version)
return
}

cfg := defaults
err := cfg.Load()
if err != nil {
Expand Down
Binary file added pg
Binary file not shown.
3 changes: 3 additions & 0 deletions powerline/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package powerline

var Version = "development"