| 193 | } |
| 194 | |
| 195 | func buildOpenCommand(goos string, cfg conf.OpenConfig, path string, category string) (string, []string, error) { |
| 196 | command := commandForCategory(cfg, category) |
| 197 | if len(command) == 0 { |
| 198 | command = defaultOpenCommand(goos, category) |
| 199 | } |
| 200 | if len(command) == 0 { |
| 201 | return "", nil, fmt.Errorf("unsupported platform: %s", goos) |
| 202 | } |
| 203 | |
| 204 | resolved := make([]string, 0, len(command)+1) |
| 205 | hasPlaceholder := false |
| 206 | for _, item := range command { |
| 207 | if item == "{path}" { |
| 208 | resolved = append(resolved, path) |
| 209 | hasPlaceholder = true |
| 210 | continue |
| 211 | } |
| 212 | resolved = append(resolved, item) |
| 213 | } |
| 214 | if !hasPlaceholder { |
| 215 | resolved = append(resolved, path) |
| 216 | } |
| 217 | |
| 218 | return resolved[0], resolved[1:], nil |
| 219 | } |
| 220 | |
| 221 | func commandForCategory(cfg conf.OpenConfig, category string) []string { |
| 222 | switch category { |