parseSource reads one file or URL argument. An http:// or https:// argument is always a link, and any `#` stays part of the URL. Like every link, a URL is read with its surrounding whitespace trimmed, which also keeps it on one result line. Any other argument is a file, and a name can follow it afte
(arg string)
| 248 | // result line. Any other argument is a file, and a name can follow it after |
| 249 | // `#`, split the way --attach splits its alt text. |
| 250 | func parseSource(arg string) (source, error) { |
| 251 | trimmed := strings.TrimSpace(arg) |
| 252 | lower := strings.ToLower(trimmed) |
| 253 | if strings.HasPrefix(lower, "http://") || strings.HasPrefix(lower, "https://") { |
| 254 | return source{kind: fromURL, arg: trimmed}, nil |
| 255 | } |
| 256 | |
| 257 | path, name := attachments.SplitFileArg(arg) |
| 258 | // Only --body-file reads standard input, and "-" is how a result line |
| 259 | // names it. |
| 260 | if path == "-" { |
| 261 | return source{}, cmdutil.FlagErrorf("cannot create an artifact from `-`; use `--body-file -` to read standard input") |
| 262 | } |
| 263 | if path != arg && name == "" { |
| 264 | return source{}, cmdutil.FlagErrorf("artifact name after `#` cannot be blank in %q", arg) |
| 265 | } |
| 266 | return source{kind: fromFile, arg: path, name: name}, nil |
| 267 | } |
| 268 | |
| 269 | // artifact is one artifact ready to create. |
| 270 | type artifact struct { |
no test coverage detected