assetFromArg turns one --attach argument into a UserAsset.
(arg string)
| 84 | |
| 85 | // assetFromArg turns one --attach argument into a UserAsset. |
| 86 | func assetFromArg(arg string) (UserAsset, error) { |
| 87 | path, alt := parseArg(arg) |
| 88 | |
| 89 | if path == "" { |
| 90 | return nil, errEmptyPath |
| 91 | } |
| 92 | |
| 93 | if path == "-" { |
| 94 | return nil, errors.New("cannot attach standard input; --attach needs a file path") |
| 95 | } |
| 96 | |
| 97 | return newAsset(path, alt) |
| 98 | } |
| 99 | |
| 100 | // parseArg splits the `path#alt text` form of an --attach argument. An existing |
| 101 | // path wins over the delimiter, since `#` is legal in filenames. |
no test coverage detected