Browse Source

Separate app filtering by id

pull/8/head
Daniel Martí 11 years ago
parent
commit
0e5d2fe8f2
  1. 28
      cmd/fdroidcl/show.go

28
cmd/fdroidcl/show.go

@ -21,24 +21,26 @@ func init() {
cmdShow.Run = runShow cmdShow.Run = runShow
} }
func runShow(args []string) { func findApps(ids []string) []*fdroidcl.App {
index := mustLoadIndex() index := mustLoadIndex()
found := make(map[string]*fdroidcl.App, len(args)) apps := make(map[string]*fdroidcl.App, len(index.Apps))
for _, appID := range args {
found[appID] = nil
}
for i := range index.Apps { for i := range index.Apps {
app := &index.Apps[i] app := &index.Apps[i]
_, e := found[app.ID] apps[app.ID] = app
if !e { }
continue result := make([]*fdroidcl.App, len(ids))
} for i, id := range ids {
found[app.ID] = app app, _ := apps[id]
result[i] = app
} }
for i, appID := range args { return result
app, _ := found[appID] }
func runShow(args []string) {
apps := findApps(args)
for i, app := range apps {
if app == nil { if app == nil {
log.Fatalf("Could not find app with ID '%s'", appID) log.Fatalf("Could not find app with ID '%s'", args[i])
} }
if i > 0 { if i > 0 {
fmt.Printf("\n--\n\n") fmt.Printf("\n--\n\n")

Loading…
Cancel
Save