(fc flags.FlagContext)
| 32 | } |
| 33 | |
| 34 | func NewSSHOptions(fc flags.FlagContext) (*SSHOptions, error) { |
| 35 | sshOptions := &SSHOptions{} |
| 36 | |
| 37 | sshOptions.AppName = fc.Args()[0] |
| 38 | sshOptions.Index = uint(fc.Int("i")) |
| 39 | sshOptions.SkipHostValidation = fc.Bool("k") |
| 40 | sshOptions.SkipRemoteExecution = fc.Bool("N") |
| 41 | sshOptions.Command = fc.StringSlice("c") |
| 42 | |
| 43 | if fc.IsSet("L") { |
| 44 | for _, arg := range fc.StringSlice("L") { |
| 45 | forwardSpec, err := sshOptions.parseLocalForwardingSpec(arg) |
| 46 | if err != nil { |
| 47 | return sshOptions, err |
| 48 | } |
| 49 | sshOptions.ForwardSpecs = append(sshOptions.ForwardSpecs, *forwardSpec) |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | if fc.IsSet("t") && fc.Bool("t") { |
| 54 | sshOptions.TerminalRequest = RequestTTYYes |
| 55 | } |
| 56 | |
| 57 | if fc.IsSet("tt") && fc.Bool("tt") { |
| 58 | sshOptions.TerminalRequest = RequestTTYForce |
| 59 | } |
| 60 | |
| 61 | if fc.Bool("T") { |
| 62 | sshOptions.TerminalRequest = RequestTTYNo |
| 63 | } |
| 64 | |
| 65 | return sshOptions, nil |
| 66 | } |
| 67 | |
| 68 | func (o *SSHOptions) parseLocalForwardingSpec(arg string) (*ForwardSpec, error) { |
| 69 | arg = strings.TrimSpace(arg) |
no test coverage detected