Browse Source

Do not export some funcs and types

pull/8/head
Daniel Martí 11 years ago
parent
commit
c8de27df64
  1. 36
      fdroidcl.go

36
fdroidcl.go

@ -44,10 +44,10 @@ type Apk struct {
MinSdk int `xml:"sdkver"` MinSdk int `xml:"sdkver"`
} }
func Form(f, str string) string { return fmt.Sprintf("\033[%sm%s\033[0m", f, str) } func form(f, str string) string { return fmt.Sprintf("\033[%sm%s\033[0m", f, str) }
func Bold(str string) string { return Form("1", str) } func bold(str string) string { return form("1", str) }
func Green(str string) string { return Form("1;32", str) } func green(str string) string { return form("1;32", str) }
func Purple(str string) string { return Form("1;35", str) } func purple(str string) string { return form("1;35", str) }
func (app *App) prepareData() { func (app *App) prepareData() {
for _, apk := range app.Apks { for _, apk := range app.Apks {
@ -58,18 +58,18 @@ func (app *App) prepareData() {
} }
} }
func (app *App) WriteShort(w io.Writer) { func (app *App) writeShort(w io.Writer) {
fmt.Fprintf(w, "%s %s %s\n", Bold(app.Name), fmt.Fprintf(w, "%s %s %s\n", bold(app.Name),
Purple(app.ID), Green(app.CurApk.VName)) purple(app.ID), green(app.CurApk.VName))
fmt.Fprintf(w, " %s\n", app.Summary) fmt.Fprintf(w, " %s\n", app.Summary)
} }
func (app *App) WriteDetailed(w io.Writer) { func (app *App) writeDetailed(w io.Writer) {
p := func(title string, format string, args ...interface{}) { p := func(title string, format string, args ...interface{}) {
if format == "" { if format == "" {
fmt.Fprintln(w, Bold(title)) fmt.Fprintln(w, bold(title))
} else { } else {
fmt.Fprintf(w, "%s %s\n", Bold(title), fmt.Sprintf(format, args...)) fmt.Fprintf(w, "%s %s\n", bold(title), fmt.Sprintf(format, args...))
} }
} }
p("Name :", "%s", app.Name) p("Name :", "%s", app.Name)
@ -186,14 +186,14 @@ func filterAppsSearch(apps *map[string]App, terms []string) {
} }
} }
type AppList []App type appList []App
func (al AppList) Len() int { return len(al) } func (al appList) Len() int { return len(al) }
func (al AppList) Swap(i, j int) { al[i], al[j] = al[j], al[i] } func (al appList) Swap(i, j int) { al[i], al[j] = al[j], al[i] }
func (al AppList) Less(i, j int) bool { return al[i].ID < al[j].ID } func (al appList) Less(i, j int) bool { return al[i].ID < al[j].ID }
func sortedApps(apps map[string]App) []App { func sortedApps(apps map[string]App) []App {
list := make(AppList, 0, len(apps)) list := make(appList, 0, len(apps))
for appID := range apps { for appID := range apps {
list = append(list, apps[appID]) list = append(list, apps[appID])
} }
@ -234,13 +234,13 @@ func main() {
case "list": case "list":
apps := loadApps() apps := loadApps()
for _, app := range sortedApps(apps) { for _, app := range sortedApps(apps) {
app.WriteShort(os.Stdout) app.writeShort(os.Stdout)
} }
case "search": case "search":
apps := loadApps() apps := loadApps()
filterAppsSearch(&apps, args) filterAppsSearch(&apps, args)
for _, app := range sortedApps(apps) { for _, app := range sortedApps(apps) {
app.WriteShort(os.Stdout) app.writeShort(os.Stdout)
} }
case "show": case "show":
apps := loadApps() apps := loadApps()
@ -249,7 +249,7 @@ func main() {
if !e { if !e {
log.Fatalf("Could not find app with ID '%s'", appID) log.Fatalf("Could not find app with ID '%s'", appID)
} }
app.WriteDetailed(os.Stdout) app.writeDetailed(os.Stdout)
} }
default: default:
fmt.Fprintf(os.Stderr, "Unrecognised command '%s'\n\n", cmd) fmt.Fprintf(os.Stderr, "Unrecognised command '%s'\n\n", cmd)

Loading…
Cancel
Save