MCPcopy Create free account
hub / github.com/cli/cli / assetFromArg

Function assetFromArg

internal/attachments/flags.go:99–111  ·  view source on GitHub ↗

assetFromArg turns one --attach argument into a UserAsset.

(arg string)

Source from the content-addressed store, hash-verified

97
98// assetFromArg turns one --attach argument into a UserAsset.
99func 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.

Callers 1

userAssetsFromArgsFunction · 0.85

Calls 2

parseArgFunction · 0.85
newAssetFunction · 0.85

Tested by

no test coverage detected