aboutsummaryrefslogtreecommitdiff
path: root/weed-fs/src/cmd/weed/command.go
diff options
context:
space:
mode:
authorTamás Gulácsi <tgulacsi78+waterhouse@gmail.com>2013-01-05 23:06:44 +0100
committerTamás Gulácsi <tgulacsi78+waterhouse@gmail.com>2013-01-05 23:06:44 +0100
commit5d2a1e8d4845e7a7f1dccd962bb0ee6a5f9d6081 (patch)
tree7fb36c1ab3b11e0e3267417c1ebbaf0ef5466a82 /weed-fs/src/cmd/weed/command.go
parent824371035109225128f8942b64a817838a7c0c25 (diff)
downloadseaweedfs-5d2a1e8d4845e7a7f1dccd962bb0ee6a5f9d6081.tar.xz
seaweedfs-5d2a1e8d4845e7a7f1dccd962bb0ee6a5f9d6081.zip
add cmd/dump - a dumper
Walk needed to be added to NeedleMap and CompactMap, to be able to add WalkKeys and WalkValues to volume. This is needed for iterating through all the stored needles in a volume - this was dump's purpose.
Diffstat (limited to 'weed-fs/src/cmd/weed/command.go')
-rw-r--r--weed-fs/src/cmd/weed/command.go59
1 files changed, 29 insertions, 30 deletions
diff --git a/weed-fs/src/cmd/weed/command.go b/weed-fs/src/cmd/weed/command.go
index 8c725cafb..4d68ff151 100644
--- a/weed-fs/src/cmd/weed/command.go
+++ b/weed-fs/src/cmd/weed/command.go
@@ -1,53 +1,52 @@
package main
import (
- "flag"
- "fmt"
- "os"
- "strings"
+ "flag"
+ "fmt"
+ "os"
+ "strings"
)
type Command struct {
- // Run runs the command.
- // The args are the arguments after the command name.
- Run func(cmd *Command, args []string) bool
+ // Run runs the command.
+ // The args are the arguments after the command name.
+ Run func(cmd *Command, args []string) bool
- // UsageLine is the one-line usage message.
- // The first word in the line is taken to be the command name.
- UsageLine string
+ // UsageLine is the one-line usage message.
+ // The first word in the line is taken to be the command name.
+ UsageLine string
- // Short is the short description shown in the 'go help' output.
- Short string
+ // Short is the short description shown in the 'go help' output.
+ Short string
- // Long is the long message shown in the 'go help <this-command>' output.
- Long string
-
- // Flag is a set of flags specific to this command.
- Flag flag.FlagSet
+ // Long is the long message shown in the 'go help <this-command>' output.
+ Long string
+ // Flag is a set of flags specific to this command.
+ Flag flag.FlagSet
}
// Name returns the command's name: the first word in the usage line.
func (c *Command) Name() string {
- name := c.UsageLine
- i := strings.Index(name, " ")
- if i >= 0 {
- name = name[:i]
- }
- return name
+ name := c.UsageLine
+ i := strings.Index(name, " ")
+ if i >= 0 {
+ name = name[:i]
+ }
+ return name
}
func (c *Command) Usage() {
- fmt.Fprintf(os.Stderr, "Example: weed %s\n", c.UsageLine)
- fmt.Fprintf(os.Stderr, "Default Usage:\n")
- c.Flag.PrintDefaults()
- fmt.Fprintf(os.Stderr, "Description:\n")
- fmt.Fprintf(os.Stderr, " %s\n", strings.TrimSpace(c.Long))
- os.Exit(2)
+ fmt.Fprintf(os.Stderr, "Example: weed %s\n", c.UsageLine)
+ fmt.Fprintf(os.Stderr, "Default Usage:\n")
+ c.Flag.PrintDefaults()
+ fmt.Fprintf(os.Stderr, "Description:\n")
+ fmt.Fprintf(os.Stderr, " %s\n", strings.TrimSpace(c.Long))
+ os.Exit(2)
}
// Runnable reports whether the command can be run; otherwise
// it is a documentation pseudo-command such as importpath.
func (c *Command) Runnable() bool {
- return c.Run != nil
+ return c.Run != nil
}