Skip to content

Commit 35eb288

Browse files
committed
adding --version
1 parent a591ab9 commit 35eb288

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

config.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ type config struct {
1818
Files files `positional-args:"yes" required:"yes"`
1919
Ignore ignorePatterns `long:"ignore" short:"i" description:"paths to ignore (glob)"`
2020
output
21-
IgnoreExcess bool `long:"ignore-excess" description:"ignore excess keys and arrey elements"`
22-
IgnoreValues bool `long:"ignore-values" description:"ignore scalar's values (only type is compared)"`
23-
OutputReport bool `long:"report" short:"r" description:"output report format"`
24-
UseSliceMyers bool `long:"slice-myers" description:"use myers algorithm for slices"`
21+
IgnoreExcess bool `long:"ignore-excess" description:"ignore excess keys and arrey elements"`
22+
IgnoreValues bool `long:"ignore-values" description:"ignore scalar's values (only type is compared)"`
23+
OutputReport bool `long:"report" short:"r" description:"output report format"`
24+
UseSliceMyers bool `long:"slice-myers" description:"use myers algorithm for slices"`
25+
Version func() `long:"version" short:"v" description:"print release version"`
2526
}
2627

2728
type output struct {
@@ -32,6 +33,10 @@ type output struct {
3233

3334
func readConfig() config {
3435
var c config
36+
c.Version = func() {
37+
fmt.Fprintf(os.Stderr, "%s\n", Version)
38+
os.Exit(0)
39+
}
3540

3641
_, err := flags.Parse(&c)
3742
if err != nil {

main.go

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ const (
1717
statusDiffMismatch = 6
1818
)
1919

20+
var (
21+
Version = "dev"
22+
)
23+
2024
func main() {
2125
var err error
2226
conf := readConfig()

0 commit comments

Comments
 (0)