Replies: 3 comments 10 replies
|
Yeah it won't work since the sources are evaluated prior to parsing flags. I think this is a case where #1273 would have helped. If you have any suggestions feel free to throw them out way |
6 replies
|
I came across this issue when working on a v2 -> v3 migration. Is this not possible with v3 anymore? |
4 replies
|
What about if type ComplexValueSourceLookup struct {
key string
}
func (c ComplexValueSourceLookup) String() string {
return fmt.Sprintf("yaml-path(%s)", c.key)
}
func (c ComplexValueSourceLookup) GoString() string {
return fmt.Sprintf("&ComplexYamlPath{key:%q}", c.key)
}
func (c ComplexValueSourceLookup) Lookup(ctx context.Context, cmd *cli.Command) (string, bool) {
endpoint, err := ssh_endpoint.ParseSshEndpoint(cmd.Args().Get(0))
if err != nil {
return "", false
}
cfg, err := nvrh_config.LoadConfig(nvrh_config.DefaultConfigPath())
if err != nil {
return "", false
}
serverConfig := cfg.Servers[endpoint.GivenHost]
value = lookup(c.key, serverConfig)
if value == "" {
return "", false
}
return value, true
}
//
cli.NewValueSourceChain(ComplexValueSourceLookup{key: "foo.bar"}) |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi
Sadly, I cant find how to implement this simple setup:
Setup is quite typical, tbh - provide custom config file and use values from it. But from docs, it looks like it may work only with hardcoded names? Any direction? Ofc, I could hack around to get config's file outside from the
clipackage, but I feel that could miss something and there is a built-in way to achieve it.Can anybody point me to what direction should I look?
P.S.: v3 of cli
All reactions