Skip to content

Commit

Permalink
Fix envars with numbers.
Browse files Browse the repository at this point in the history
Fixes #138.
  • Loading branch information
alecthomas committed Aug 29, 2016
1 parent e590021 commit e9044be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var (
)

var (
envarTransformRegexp = regexp.MustCompile(`[^a-zA-Z_]+`)
envarTransformRegexp = regexp.MustCompile(`[^a-zA-Z0-9_]+`)
)

type ApplicationValidator func(*Application) error
Expand Down
3 changes: 3 additions & 0 deletions app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,13 @@ func TestDefaultEnvars(t *testing.T) {
f0.Bool()
f1 := a.Flag("some-other-flag", "").NoEnvar()
f1.Bool()
f2 := a.Flag("a-1-flag", "")
f2.Bool()
_, err := a.Parse([]string{})
assert.NoError(t, err)
assert.Equal(t, "SOME_APP_SOME_FLAG", f0.envar)
assert.Equal(t, "", f1.envar)
assert.Equal(t, "SOME_APP_A_1_FLAG", f2.envar)
}

func TestBashCompletionOptionsWithEmptyApp(t *testing.T) {
Expand Down

0 comments on commit e9044be

Please sign in to comment.