Export default parser

Signed-off-by: Derek Nola <derek.nola@suse.com>
pull/4621/head
Derek Nola 3 years ago
parent 12581188e8
commit 9cc930e4a3

@ -7,7 +7,7 @@ import (
"github.com/urfave/cli" "github.com/urfave/cli"
) )
var defaultParser = &Parser{ var DefaultParser = &Parser{
After: []string{"server", "agent", "etcd-snapshot:1"}, After: []string{"server", "agent", "etcd-snapshot:1"},
FlagNames: []string{"--config", "-c"}, FlagNames: []string{"--config", "-c"},
EnvName: version.ProgramUpper + "_CONFIG_FILE", EnvName: version.ProgramUpper + "_CONFIG_FILE",
@ -16,7 +16,7 @@ var defaultParser = &Parser{
} }
func MustParse(args []string) []string { func MustParse(args []string) []string {
result, err := defaultParser.Parse(args) result, err := DefaultParser.Parse(args)
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }

@ -65,7 +65,7 @@ func Test_UnitMustParse(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
defaultParser.DefaultConfig = tt.config DefaultParser.DefaultConfig = tt.config
if got := MustParse(tt.args); !reflect.DeepEqual(got, tt.want) { if got := MustParse(tt.args); !reflect.DeepEqual(got, tt.want) {
t.Errorf("MustParse() = %+v\nWant = %+v", got, tt.want) t.Errorf("MustParse() = %+v\nWant = %+v", got, tt.want)
} }

Loading…
Cancel
Save