From 286b62f1ab735a16ce557fe383b416ef7a773335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sat, 10 Sep 2016 10:14:26 +0200 Subject: [PATCH] fdroidcl: delay looking up a device This way, we can error e.g. on a bad category without unnecessarily waiting for a device. Also gofmt. --- cmd/fdroidcl/search.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/fdroidcl/search.go b/cmd/fdroidcl/search.go index cfaae0c..76e4491 100644 --- a/cmd/fdroidcl/search.go +++ b/cmd/fdroidcl/search.go @@ -44,10 +44,6 @@ func runSearch(args []string) { fmt.Fprintf(os.Stderr, "%v\n", err) cmdSearch.Flag.Usage() } - var device *adb.Device - if *installed || *updates { - device = mustOneDevice() - } apps := mustLoadIndexes() if len(apps) > 0 && *category != "" { apps = filterAppsCategory(apps, *category) @@ -59,6 +55,10 @@ func runSearch(args []string) { if len(apps) > 0 && len(args) > 0 { apps = filterAppsSearch(apps, args) } + var device *adb.Device + if *installed || *updates { + device = mustOneDevice() + } if len(apps) > 0 && *installed { apps = filterAppsInstalled(apps, device) } @@ -202,7 +202,7 @@ func filterAppsLastUpdated(apps []fdroidcl.App, days int) []fdroidcl.App { days = -days newer = false } - date := time.Now().Truncate(24 * time.Hour).AddDate(0, 0, 1 - days) + date := time.Now().Truncate(24*time.Hour).AddDate(0, 0, 1-days) for _, app := range apps { if app.Updated.Before(date) == newer { continue