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

Function userAssetsFromArgs

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

Source from the content-addressed store, hash-verified

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