mirror of https://github.com/perkeep/perkeep.git
Merge "cmdmain: sort Modes and Examples"
This commit is contained in:
commit
ed07089172
|
@ -25,6 +25,7 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
"perkeep.org/pkg/buildinfo"
|
||||
|
@ -135,23 +136,36 @@ Usage: ` + cmdName + ` [globalopts] <mode> [commandopts] [commandargs]
|
|||
Modes:
|
||||
|
||||
`)
|
||||
var modes []string
|
||||
for mode, cmd := range modeCommand {
|
||||
if des, ok := cmd.(describer); ok {
|
||||
Errorf(" %s: %s\n", mode, des.Describe())
|
||||
modes = append(modes, fmt.Sprintf(" %s: %s\n", mode, des.Describe()))
|
||||
}
|
||||
}
|
||||
sort.Strings(modes)
|
||||
for i := range modes {
|
||||
Errorf("%s", modes[i])
|
||||
}
|
||||
|
||||
Errorf("\nExamples:\n")
|
||||
modes = nil
|
||||
for mode, cmd := range modeCommand {
|
||||
if ex, ok := cmd.(exampler); ok {
|
||||
line := ""
|
||||
exs := ex.Examples()
|
||||
if len(exs) > 0 {
|
||||
Errorf("\n")
|
||||
line = "\n"
|
||||
}
|
||||
for _, example := range exs {
|
||||
Errorf(" %s %s %s\n", cmdName, mode, example)
|
||||
line += fmt.Sprintf(" %s %s %s\n", cmdName, mode, example)
|
||||
}
|
||||
modes = append(modes, line)
|
||||
}
|
||||
}
|
||||
sort.Strings(modes)
|
||||
for i := range modes {
|
||||
Errorf("%s", modes[i])
|
||||
}
|
||||
|
||||
Errorf(`
|
||||
For mode-specific help:
|
||||
|
|
Loading…
Reference in New Issue