diff --git a/README.md b/README.md index 6905a3d..a6ca926 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,8 @@ Install an app: uninstall Uninstall an app defaults Reset to the default settings + A specific version of an app can be selected by following the appid with an colon (:) and the version code of the app to select. + ### Config You can configure the repositories to use in the `config.json` file, diff --git a/cmd/fdroidcl/main.go b/cmd/fdroidcl/main.go index a385899..0ef3234 100644 --- a/cmd/fdroidcl/main.go +++ b/cmd/fdroidcl/main.go @@ -140,6 +140,7 @@ func init() { fmt.Fprintf(os.Stderr, " %s%s %s\n", c.UsageLine, strings.Repeat(" ", maxUsageLen-len(c.UsageLine)), c.Short) } + fmt.Fprintf(os.Stderr, "\nA specific version of an app can be selected by following the appid with an colon (:) and the version code of the app to select.\n") fmt.Fprintf(os.Stderr, "\nUse %s -h for more info\n", cmdName) } } diff --git a/cmd/fdroidcl/show.go b/cmd/fdroidcl/show.go index 708ce4d..8aaee15 100644 --- a/cmd/fdroidcl/show.go +++ b/cmd/fdroidcl/show.go @@ -7,6 +7,7 @@ import ( "fmt" "log" "os" + "strconv" "strings" "github.com/mvdan/fdroidcl" @@ -47,10 +48,34 @@ func findApps(ids []string) []*fdroidcl.App { apps := appsMap(mustLoadIndexes()) result := make([]*fdroidcl.App, len(ids)) for i, id := range ids { + var vcode = -1 + j := strings.Index(id, ":") + if j > -1 { + var err error + vcode, err = strconv.Atoi(id[j+1:]) + if err != nil { + log.Fatalf("Could not parse version code from '%s'", id) + } + id = id[:j] + } + app, e := apps[id] if !e { log.Fatalf("Could not find app with ID '%s'", id) } + + if vcode > -1 { + found := false + for _, apk := range app.Apks { + if apk.VCode == vcode { + app.Apks = []fdroidcl.Apk{apk} + found = true + } + } + if !found { + log.Fatalf("Could not find version %d for app with ID '%s'", vcode, id) + } + } result[i] = app } return result