Skip to content

Commit 9dc2166

Browse files
committed
Improve --asset
1 parent cefe763 commit 9dc2166

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

detect.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,21 @@ type SingleAssetDetector struct {
150150
}
151151

152152
func (s *SingleAssetDetector) Detect(assets []string) (string, []string, error) {
153+
var candidates []string
153154
for _, a := range assets {
154-
if strings.Contains(path.Base(a), s.Asset) {
155+
if path.Base(a) == s.Asset {
155156
return a, nil, nil
156157
}
158+
if strings.Contains(path.Base(a), s.Asset) {
159+
candidates = append(candidates, a)
160+
}
161+
}
162+
if len(candidates) == 1 {
163+
return candidates[0], nil, nil
164+
} else if len(candidates) > 1 {
165+
return "", candidates, fmt.Errorf("%d candidates found for asset `%s`", len(candidates), s.Asset)
157166
}
158-
return "", nil, fmt.Errorf("asset %s not found", s.Asset)
167+
return "", nil, fmt.Errorf("asset `%s` not found", s.Asset)
159168
}
160169

161170
// A SystemDetector matches a particular OS/Arch system pair.

man/eget.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ header: Eget Manual
5555

5656
`--asset=`
5757

58-
: Download a specific asset containing the given string. Example: **`eget --asset nvim.appimage neovim/neovim`**.
58+
: Download a specific asset containing the given string. If there is an exact match with an asset, that asset is used regardless. Example: **`eget --asset nvim.appimage neovim/neovim`**.
5959

6060
`-x`
6161

0 commit comments

Comments
 (0)