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

Function assetFromArg

internal/attachments/flags.go:86–98  ·  view source on GitHub ↗

assetFromArg turns one --attach argument into a UserAsset.

(arg string)

Source from the content-addressed store, hash-verified

84
85// assetFromArg turns one --attach argument into a UserAsset.
86func 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.

Callers 1

userAssetsFromArgsFunction · 0.85

Calls 2

parseArgFunction · 0.85
newAssetFunction · 0.85

Tested by

no test coverage detected