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

Function userAssetsFromArgs

internal/attachments/flags.go:60–83  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

58}
59
60func userAssetsFromArgs(args []string) ([]UserAsset, error) {
61 // --attach "" is a user error.
62 if len(args) == 0 {
63 return nil, errEmptyPath
64 }
65
66 resolvedAssets := make([]UserAsset, 0, len(args))
67 for _, arg := range args {
68 a, err := assetFromArg(arg)
69 if err != nil {
70 return nil, err
71 }
72
73 // The same file under two names is a user error.
74 for _, seen := range resolvedAssets {
75 if os.SameFile(seen.getAsset().info, a.getAsset().info) {
76 return nil, fmt.Errorf("%s and %s are the same file; attached files must be unique", seen.Path(), a.Path())
77 }
78 }
79 resolvedAssets = append(resolvedAssets, a)
80 }
81
82 return resolvedAssets, nil
83}
84
85// assetFromArg turns one --attach argument into a UserAsset.
86func assetFromArg(arg string) (UserAsset, error) {

Callers 1

UserAssetsMethod · 0.85

Calls 4

assetFromArgFunction · 0.85
getAssetMethod · 0.65
ErrorfMethod · 0.65
PathMethod · 0.65

Tested by

no test coverage detected