| 17 | type GetAllProxiesCallback func() ([]*proxies.Proxy, error) |
| 18 | |
| 19 | func PromptForProxy(opts *CreateTargetProxyOptions, flags *CreateTargetProxyFlags, description string) error { |
| 20 | if flags.Proxy.Value == "" { |
| 21 | directConnection := true |
| 22 | opts.Ask(&survey.Confirm{ |
| 23 | Message: fmt.Sprintf("Should the connection to the %s be direct?", description), |
| 24 | Default: true, |
| 25 | }, &directConnection) |
| 26 | if !directConnection { |
| 27 | selectedOption, err := selectors.Select(opts.Ask, "Select the proxy to use", opts.GetAllProxiesCallback, func(p *proxies.Proxy) string { return p.GetName() }) |
| 28 | if err != nil { |
| 29 | return err |
| 30 | } |
| 31 | flags.Proxy.Value = selectedOption.GetName() |
| 32 | } |
| 33 | } |
| 34 | return nil |
| 35 | } |
| 36 | |
| 37 | type CreateTargetProxyFlags struct { |
| 38 | Proxy *flag.Flag[string] |