Browse Source

fdroidcl: add `list categories`

Useful to know what can go in `search -c`, either for humans or for
completion scripts.

Fixes #12.
pull/16/head
Daniel Martí 10 years ago
parent
commit
02aa950697
  1. BIN
      cmd/fdroidcl/cpu.out
  2. 47
      cmd/fdroidcl/list.go
  3. 1
      cmd/fdroidcl/main.go

BIN
cmd/fdroidcl/cpu.out

Binary file not shown.

47
cmd/fdroidcl/list.go

@ -0,0 +1,47 @@
// Copyright (c) 2015, Daniel Martí <mvdan@mvdan.cc>
// See LICENSE for licensing information
package main
import (
"fmt"
"os"
"sort"
)
var cmdList = &Command{
UsageLine: "list (categories)",
Short: "List all known values of a kind",
}
func init() {
cmdList.Run = runList
}
func runList(args []string) {
if len(args) != 1 {
fmt.Fprintf(os.Stderr, "need exactly one argument")
cmdList.Flag.Usage()
}
apps := mustLoadIndexes()
values := make(map[string]struct{})
switch args[0] {
case "categories":
for _, app := range apps {
for _, c := range app.Categs {
values[c] = struct{}{}
}
}
default:
fmt.Fprintf(os.Stderr, "invalid argument")
cmdList.Flag.Usage()
}
result := make([]string, 0, len(values))
for s := range values {
result = append(result, s)
}
sort.Strings(result)
for _, s := range result {
fmt.Println(s)
}
}

1
cmd/fdroidcl/main.go

@ -148,6 +148,7 @@ var commands = []*Command{
cmdUpdate,
cmdSearch,
cmdShow,
cmdList,
cmdDevices,
cmdDownload,
cmdInstall,

Loading…
Cancel
Save