mirror of https://github.com/perkeep/perkeep.git
Merge "cmdmain, cmd/pk: support for demoting prominence of some subcommands"
This commit is contained in:
commit
0c28468f65
|
@ -69,6 +69,8 @@ func init() {
|
|||
})
|
||||
}
|
||||
|
||||
func (c *dbinitCmd) Demote() bool { return true }
|
||||
|
||||
func (c *dbinitCmd) Describe() string {
|
||||
return "Set up the database for the indexer."
|
||||
}
|
||||
|
|
|
@ -53,6 +53,8 @@ func init() {
|
|||
})
|
||||
}
|
||||
|
||||
func (c *debugCmd) Demote() bool { return true }
|
||||
|
||||
func (c *debugCmd) Describe() string {
|
||||
return "Show misc meta-info from the given file."
|
||||
}
|
||||
|
|
|
@ -39,6 +39,8 @@ func init() {
|
|||
})
|
||||
}
|
||||
|
||||
func (c *discoCmd) Demote() bool { return true }
|
||||
|
||||
func (c *discoCmd) Describe() string {
|
||||
return "Perform configuration discovery against a server."
|
||||
}
|
||||
|
|
|
@ -44,6 +44,8 @@ func init() {
|
|||
})
|
||||
}
|
||||
|
||||
func (c *reindexdpCmd) Demote() bool { return true }
|
||||
|
||||
func (c *reindexdpCmd) Describe() string {
|
||||
return "Rebuild the index of the diskpacked blob store"
|
||||
}
|
||||
|
|
|
@ -44,6 +44,8 @@ func init() {
|
|||
})
|
||||
}
|
||||
|
||||
func (c *googinitCmd) Demote() bool { return true }
|
||||
|
||||
func (c *googinitCmd) Describe() string {
|
||||
return "Init Google Drive or Google Cloud Storage."
|
||||
}
|
||||
|
|
|
@ -34,7 +34,9 @@ type indexCmd struct {
|
|||
func init() {
|
||||
cmdmain.RegisterMode("index", func(flags *flag.FlagSet) cmdmain.CommandRunner {
|
||||
cmd := new(indexCmd)
|
||||
flags.BoolVar(&cmd.wipe, "wipe", false, "Erase and recreate all discovered indexes. NOOP for now.")
|
||||
|
||||
// TODO: add client-initiated wipe support?
|
||||
// flags.BoolVar(&cmd.wipe, "wipe", false, "Erase and recreate all discovered indexes. NOOP for now.")
|
||||
if debug, _ := strconv.ParseBool(os.Getenv("CAMLI_DEBUG")); debug {
|
||||
flags.BoolVar(&cmd.insecureTLS, "insecure", false, "If set, when using TLS, the server's certificates verification is disabled, and they are not checked against the trustedCerts in the client configuration either.")
|
||||
}
|
||||
|
@ -42,8 +44,10 @@ func init() {
|
|||
})
|
||||
}
|
||||
|
||||
func (c *indexCmd) Demote() bool { return true }
|
||||
|
||||
func (c *indexCmd) Describe() string {
|
||||
return "Synchronize blobs for all discovered blobs storage - indexer pairs."
|
||||
return "Synchronize blobs for all discovered blobs storage -> indexer sync pairs."
|
||||
}
|
||||
|
||||
func (c *indexCmd) Usage() {
|
||||
|
|
|
@ -40,6 +40,8 @@ func init() {
|
|||
})
|
||||
}
|
||||
|
||||
func (c *packBlobsCmd) Demote() bool { return true }
|
||||
|
||||
func (c *packBlobsCmd) Describe() string {
|
||||
return "Pack related blobs together (migration tool)"
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ func (c *searchCmd) Usage() {
|
|||
func (c *searchCmd) Examples() []string {
|
||||
return []string{
|
||||
`"loc:paris is:portrait" # expression`,
|
||||
`'{"blobrefPrefix":"sha1-f00d"}' # SearchConstraint JSON`,
|
||||
`'{"blobrefPrefix":"sha224-f00d"}' # SearchConstraint JSON`,
|
||||
`- # piped from stdin`,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ func init() {
|
|||
}
|
||||
|
||||
func (c *syncCmd) Describe() string {
|
||||
return "Synchronize blobs from a source to a destination."
|
||||
return "(Re)synchronize blobs from a source to a destination."
|
||||
}
|
||||
|
||||
func (c *syncCmd) Usage() {
|
||||
|
@ -370,7 +370,7 @@ func (c *syncCmd) doPass(src, dest, thirdLeg blobserver.Storage) (stats SyncStat
|
|||
if c.wipe {
|
||||
// TODO(mpl): dest is a client. make it send a "wipe" request?
|
||||
// upon reception its server then wipes itself if it is a wiper.
|
||||
log.Print("Index wiping not yet supported.")
|
||||
log.Fatal("Index wiping not yet supported.")
|
||||
}
|
||||
|
||||
go enumerate(destErr, dest, destBlobs)
|
||||
|
|
|
@ -105,6 +105,14 @@ type ExecRunner interface {
|
|||
LookPath() (string, error)
|
||||
}
|
||||
|
||||
// Demoter is an interface that boring commands can implement to
|
||||
// demote themselves in the tool listing, for boring or low-level
|
||||
// subcommands. They only show up in --help mode.
|
||||
type Demoter interface {
|
||||
CommandRunner
|
||||
Demote() bool
|
||||
}
|
||||
|
||||
type exampler interface {
|
||||
Examples() []string
|
||||
}
|
||||
|
@ -113,6 +121,11 @@ type describer interface {
|
|||
Describe() string
|
||||
}
|
||||
|
||||
func demote(c CommandRunner) bool {
|
||||
i, ok := c.(Demoter)
|
||||
return ok && i.Demote()
|
||||
}
|
||||
|
||||
// RegisterMode adds a mode to the list of modes for the main command.
|
||||
// It is meant to be called in init() for each subcommand.
|
||||
func RegisterMode(mode string, makeCmd func(Flags *flag.FlagSet) CommandRunner) {
|
||||
|
@ -151,15 +164,19 @@ func usage(msg string) {
|
|||
if msg != "" {
|
||||
Errorf("Error: %v\n", msg)
|
||||
}
|
||||
var modesQualifer string
|
||||
if !*FlagHelp {
|
||||
modesQualifer = " (use --help to see all modes)"
|
||||
}
|
||||
Errorf(`
|
||||
Usage: ` + cmdName + ` [globalopts] <mode> [commandopts] [commandargs]
|
||||
Usage: `+cmdName+` [globalopts] <mode> [commandopts] [commandargs]
|
||||
|
||||
Modes:
|
||||
Modes:%s
|
||||
|
||||
`)
|
||||
`, modesQualifer)
|
||||
var modes []string
|
||||
for mode, cmd := range modeCommand {
|
||||
if des, ok := cmd.(describer); ok {
|
||||
if des, ok := cmd.(describer); ok && (*FlagHelp || !demote(cmd)) {
|
||||
modes = append(modes, fmt.Sprintf(" %s: %s\n", mode, des.Describe()))
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +188,7 @@ Modes:
|
|||
Errorf("\nExamples:\n")
|
||||
modes = nil
|
||||
for mode, cmd := range modeCommand {
|
||||
if ex, ok := cmd.(exampler); ok {
|
||||
if ex, ok := cmd.(exampler); ok && (*FlagHelp || !demote(cmd)) {
|
||||
line := ""
|
||||
exs := ex.Examples()
|
||||
if len(exs) > 0 {
|
||||
|
@ -250,7 +267,7 @@ func Main() {
|
|||
|
||||
args := flag.Args()
|
||||
if *FlagVersion {
|
||||
fmt.Fprintf(Stderr, "%s version: %s\n", os.Args[0], buildinfo.Version())
|
||||
fmt.Fprintf(Stderr, "%s version: %s\n", os.Args[0], buildinfo.Summary())
|
||||
return
|
||||
}
|
||||
if *FlagHelp {
|
||||
|
|
Loading…
Reference in New Issue