Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input: Regexp type for kelseyhightower/envconfig integration #4

Open
kamilsk opened this issue May 14, 2022 · 0 comments
Open

input: Regexp type for kelseyhightower/envconfig integration #4

kamilsk opened this issue May 14, 2022 · 0 comments
Assignees
Labels
difficulty: easy Issue is easy to implement. kind: feature New feature request. scope: code Issue related to source code. scope: test Issue related to tests.

Comments

@kamilsk
Copy link
Member

kamilsk commented May 14, 2022

Motivation: extend flag types.

Draft

type Regexp regexp.Regexp

func (reg *Regexp) Decode(value string) error {
	raw, err := regexp.Compile(fmt.Sprintf(`^%s$`, value))
	if err != nil {
		return err
	}

	*reg = Regexp(*raw)
	return nil
}

func (reg *Regexp) Matcher() *regexp.Regexp {
	return (*regexp.Regexp)(reg)
}

See https://github.com/kelseyhightower/envconfig#custom-decoders.

@kamilsk kamilsk added the kind: improvement New improvement proposal. label May 14, 2022
@kamilsk kamilsk self-assigned this May 14, 2022
@kamilsk kamilsk changed the title exp: Regexp type for github.com/kelseyhightower/envconfig integration exp: Regexp type for kelseyhightower/envconfig integration May 14, 2022
@kamilsk kamilsk changed the title exp: Regexp type for kelseyhightower/envconfig integration integration: Regexp type for kelseyhightower/envconfig integration May 27, 2022
@kamilsk kamilsk changed the title integration: Regexp type for kelseyhightower/envconfig integration input: Regexp type for kelseyhightower/envconfig integration May 27, 2022
@kamilsk kamilsk added difficulty: easy Issue is easy to implement. scope: code Issue related to source code. scope: test Issue related to tests. kind: feature New feature request. and removed kind: improvement New improvement proposal. labels May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: easy Issue is easy to implement. kind: feature New feature request. scope: code Issue related to source code. scope: test Issue related to tests.
Projects
Status: Backlog
Development

No branches or pull requests

1 participant