assetFromArg turns one --attach argument into a UserAsset.
(arg string)
| 97 | |
| 98 | // assetFromArg turns one --attach argument into a UserAsset. |
| 99 | func assetFromArg(arg string) (UserAsset, error) { |
| 100 | path, alt := parseArg(arg) |
| 101 | |
| 102 | if path == "" { |
| 103 | return nil, errEmptyPath |
| 104 | } |
| 105 | |
| 106 | if path == "-" { |
| 107 | return nil, errors.New("cannot attach standard input; --attach needs a file path") |
| 108 | } |
| 109 | |
| 110 | return newAsset(path, alt) |
| 111 | } |
| 112 | |
| 113 | // parseArg splits the `path#alt text` form of an --attach argument. An existing |
| 114 | // path wins over the delimiter, since `#` is legal in filenames. |
no test coverage detected