mirror of https://github.com/mvdan/fdroidcl.git
3 changed files with 103 additions and 30 deletions
@ -0,0 +1,34 @@
|
||||
/* Copyright (c) 2015, Daniel Martí <mvdan@mvdan.cc> */ |
||||
/* See LICENSE for licensing information */ |
||||
|
||||
package main |
||||
|
||||
import ( |
||||
"github.com/mvdan/fdroidcl" |
||||
) |
||||
|
||||
var cmdList = &Command{ |
||||
Name: "list", |
||||
Short: "List all available apps", |
||||
} |
||||
|
||||
func init() { |
||||
cmdList.Run = runList |
||||
} |
||||
|
||||
func runList(args []string) { |
||||
index := mustLoadIndex() |
||||
printApps(index.Apps) |
||||
} |
||||
|
||||
func printApps(apps []fdroidcl.App) { |
||||
maxIDLen := 0 |
||||
for _, app := range apps { |
||||
if len(app.ID) > maxIDLen { |
||||
maxIDLen = len(app.ID) |
||||
} |
||||
} |
||||
for _, app := range apps { |
||||
printApp(app, maxIDLen) |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@
|
||||
/* Copyright (c) 2015, Daniel Martí <mvdan@mvdan.cc> */ |
||||
/* See LICENSE for licensing information */ |
||||
|
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"log" |
||||
) |
||||
|
||||
var cmdUpdate = &Command{ |
||||
Name: "update", |
||||
Short: "Update the index", |
||||
} |
||||
|
||||
func init() { |
||||
cmdUpdate.Run = runUpdate |
||||
} |
||||
|
||||
func runUpdate(args []string) { |
||||
if err := updateIndex(); err != nil { |
||||
log.Fatalf("Could not update index: %v", err) |
||||
} |
||||
} |
||||
|
||||
func updateIndex() error { |
||||
url := fmt.Sprintf("%s/%s", repoURL, "index.jar") |
||||
if err := downloadEtag(url, indexPath(repoName)); err != nil { |
||||
return err |
||||
} |
||||
return nil |
||||
} |
||||
Loading…
Reference in new issue