(input string)
| 29 | var userHostRe = regexp.MustCompile(`^([a-zA-Z0-9][a-zA-Z0-9._@\\-]*@)?([a-zA-Z0-9][a-zA-Z0-9.-]*)(?::([0-9]+))?$`) |
| 30 | |
| 31 | func ParseOpts(input string) (*SSHOpts, error) { |
| 32 | m := userHostRe.FindStringSubmatch(input) |
| 33 | if m == nil { |
| 34 | return nil, fmt.Errorf("invalid format of user@host argument") |
| 35 | } |
| 36 | remoteUser, remoteHost, remotePort := m[1], m[2], m[3] |
| 37 | remoteUser = strings.Trim(remoteUser, "@") |
| 38 | |
| 39 | return &SSHOpts{SSHHost: remoteHost, SSHUser: remoteUser, SSHPort: remotePort}, nil |
| 40 | } |
| 41 | |
| 42 | func normalizeOs(os string) string { |
| 43 | os = strings.ToLower(strings.TrimSpace(os)) |
no outgoing calls
no test coverage detected