File tree 5 files changed +11
-16
lines changed
5 files changed +11
-16
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,13 @@ import "github.com/spf13/cobra"
4
4
5
5
type Option func (cmd * cobra.Command )
6
6
7
+ func WithVersion (version string ) Option {
8
+ return func (cmd * cobra.Command ) {
9
+ cmd .Version = buildVersion (version )
10
+ cmd .InitDefaultVersionFlag ()
11
+ }
12
+ }
13
+
7
14
const DisableTTYAnnotation = "without"
8
15
9
16
func DisableTTY () Option {
Original file line number Diff line number Diff line change 1
- package cmd
1
+ package cmdutil
2
2
3
3
import "runtime/debug"
4
4
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ func main() {
31
31
panic (err )
32
32
}
33
33
34
- opts := []cmdutil.Option {cmd .WithVersion ("beta" )}
34
+ opts := []cmdutil.Option {cmdutil .WithVersion ("beta" )}
35
35
root := cmd .New (cmd .Name , opts ... )
36
36
cmds := append (slices .Collect (subcommands .Without (nil , opts ... )), root )
37
37
for _ , subCmd := range root .Commands () {
Original file line number Diff line number Diff line change @@ -6,12 +6,13 @@ import (
6
6
"os/exec"
7
7
8
8
"github.com/gabe565/moreutils/cmd"
9
+ "github.com/gabe565/moreutils/cmd/cmdutil"
9
10
)
10
11
11
12
var version = "beta"
12
13
13
14
func main () {
14
- root := cmd .New (os .Args [0 ], cmd .WithVersion (version ))
15
+ root := cmd .New (os .Args [0 ], cmdutil .WithVersion (version ))
15
16
root .SilenceErrors = true
16
17
if err := root .Execute (); err != nil {
17
18
var execErr * exec.ExitError
You can’t perform that action at this time.
0 commit comments