diff --git a/cmd/fdroidcl/cpu.out b/cmd/fdroidcl/cpu.out new file mode 100644 index 0000000..883342a Binary files /dev/null and b/cmd/fdroidcl/cpu.out differ diff --git a/cmd/fdroidcl/list.go b/cmd/fdroidcl/list.go new file mode 100644 index 0000000..b258169 --- /dev/null +++ b/cmd/fdroidcl/list.go @@ -0,0 +1,47 @@ +// Copyright (c) 2015, Daniel Martí +// 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) + } +} diff --git a/cmd/fdroidcl/main.go b/cmd/fdroidcl/main.go index a01daab..2d41939 100644 --- a/cmd/fdroidcl/main.go +++ b/cmd/fdroidcl/main.go @@ -148,6 +148,7 @@ var commands = []*Command{ cmdUpdate, cmdSearch, cmdShow, + cmdList, cmdDevices, cmdDownload, cmdInstall,