Browse Source

Add a download subcommand

pull/8/head
Daniel Martí 11 years ago
parent
commit
4149e65b3b
  1. 1
      README.md
  2. 40
      cmd/fdroidcl/download.go
  3. 6
      cmd/fdroidcl/install.go
  4. 1
      cmd/fdroidcl/main.go

1
README.md

@ -17,6 +17,7 @@ your own risk.
search <regexp...> Search available apps
show <appid...> Show detailed info about an app
devices List connected devices
download <appid...> Download an app
install <appid...> Install an app
uninstall <appid...> Uninstall an app

40
cmd/fdroidcl/download.go

@ -0,0 +1,40 @@
// Copyright (c) 2015, Daniel Martí <mvdan@mvdan.cc>
// See LICENSE for licensing information
package main
import (
"fmt"
"log"
"path/filepath"
)
var cmdDownload = &Command{
UsageLine: "download <appid...>",
Short: "Download an app",
}
func init() {
cmdDownload.Run = runDownload
}
func runDownload(args []string) {
if len(args) < 1 {
log.Fatalf("No package names given")
}
apps := findApps(args)
for _, app := range apps {
apk := app.CurApk
url := fmt.Sprintf("%s/%s", apk.Repo.URL, apk.ApkName)
path := apkPath(apk.ApkName)
if err := downloadEtag(url, path, apk.Hash.Data); err != nil {
log.Fatalf("Could not download '%s': %v", app.ID, err)
}
fmt.Printf("APK available in %s\n", path)
}
}
func apkPath(apkname string) string {
apksDir := subdir(mustCache(), "apks")
return filepath.Join(apksDir, apkname)
}

6
cmd/fdroidcl/install.go

@ -6,7 +6,6 @@ package main
import (
"fmt"
"log"
"path/filepath"
)
var cmdInstall = &Command{
@ -44,8 +43,3 @@ func runInstall(args []string) {
fmt.Println("done")
}
}
func apkPath(apkname string) string {
apksDir := subdir(mustCache(), "apks")
return filepath.Join(apksDir, apkname)
}

1
cmd/fdroidcl/main.go

@ -152,6 +152,7 @@ var commands = []*Command{
cmdSearch,
cmdShow,
cmdDevices,
cmdDownload,
cmdInstall,
cmdUninstall,
}

Loading…
Cancel
Save