Export default parser

Signed-off-by: Derek Nola <derek.nola@suse.com>
(cherry picked from commit 9cc930e4a3)
This commit is contained in:
Derek Nola 2021-12-01 12:06:51 -08:00 committed by Brad Davidson
parent d0f7e23328
commit ff49dcf71e
2 changed files with 3 additions and 3 deletions

View File

@ -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)
} }

View File

@ -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)
} }