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 := SplitFileArg(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// SplitFileArg splits an argument of the form <file>#<text>, the way --attach
101// reads '<file>#<image alt text>'. An existing path wins over the delimiter,

Callers 1

userAssetsFromArgsFunction · 0.85

Calls 2

SplitFileArgFunction · 0.85
newAssetFunction · 0.85

Tested by

no test coverage detected