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

Function userAssetsFromArgs

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

Source from the content-addressed store, hash-verified

71}
72
73func userAssetsFromArgs(args []string) ([]UserAsset, error) {
74 // --attach "" is a user error.
75 if len(args) == 0 {
76 return nil, errEmptyPath
77 }
78
79 resolvedAssets := make([]UserAsset, 0, len(args))
80 for _, arg := range args {
81 a, err := assetFromArg(arg)
82 if err != nil {
83 return nil, err
84 }
85
86 // The same file under two names is a user error.
87 for _, seen := range resolvedAssets {
88 if os.SameFile(seen.getAsset().info, a.getAsset().info) {
89 return nil, fmt.Errorf("%s and %s are the same file; attached files must be unique", seen.Path(), a.Path())
90 }
91 }
92 resolvedAssets = append(resolvedAssets, a)
93 }
94
95 return resolvedAssets, nil
96}
97
98// assetFromArg turns one --attach argument into a UserAsset.
99func 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