-
Notifications
You must be signed in to change notification settings - Fork 153
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
adds urfave/cli/v2 flag parser #330
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firstly, Great work!
I was going to create an issue to support urfave/cli I'm very glad I didn't and looked at PR's first.
I am currently using v3, I left a few comments here, let me know your opinion.
If you want to stay with v2, I will gladly make a PR for v3, but I suggest you also version this one so they can both live on the same repo under the same name :)
"strings" | ||
|
||
"github.com/knadh/koanf/maps" | ||
"github.com/urfave/cli/v2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v3 is on the verge of being released:
It may well be worth it to either version this provider behind /v2 or jump to /v3 right away.
|
||
// CliFlag implements a cli.Flag command line provider. | ||
type CliFlag struct { | ||
ctx *cli.Context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v3 will help to remove this custom context and rely on context.Context instead.
https://github.com/urfave/cli/tree/main/docs/v3
migration: https://github.com/urfave/cli/blob/main/docs/migrate-v2-to-v3.md#clicontext-has-been-removed
It also makes a much saner API for all the methods below.
Passing the cli.Command could also result in a less opinionated way of parsing flags in koanf.
cmdPath = append(cmdPath, cmd.Command.Name) | ||
prefix := strings.Join(cmdPath, p.delim) | ||
p.processFlags(cmd.Command.Flags, prefix, out) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the user should provide flag to key mappings.
This leads to an opinionated way to create the returned map keys.
I understand the intention to travel all the command and parse all flags but maybe that is not what any user would want.
I have looked into urfave/cli to see if there is a way to indicate which flags will be used as config and which aren't, but there isn't a way for this. So maybe there is a way to let user of Koanf the ability to say which flags are or aren't to be handled.
No description provided.