veyron/tools/mounttable: defaulting mounttable name to "" if unspecified for Glob
Globbing the default mounttable (at defaultNamespaceRoot) is a common task.
Currently, one has to run: ./mounttable glob "" "..." because the mounttable
name argument is required. This CL makes it optional, defaulting it to "".
Change-Id: I6b5c7b32203248285ad70a3fcaabe0478a365f2a
diff --git a/tools/mounttable/impl.go b/tools/mounttable/impl.go
index 1cb8aac..8778b54 100644
--- a/tools/mounttable/impl.go
+++ b/tools/mounttable/impl.go
@@ -35,15 +35,18 @@
Name: "glob",
Short: "returns all matching entries in the mount table",
Long: "returns all matching entries in the mount table",
- ArgsName: "<mount name> <pattern>",
+ ArgsName: "[<mount name>] <pattern>",
ArgsLong: `
-<mount name> is a mount name on a mount table.
+<mount name> is a mount name on a mount table. Defaults to namespace root.
<pattern> is a glob pattern that is matched against all the entries below the
specified mount name.
`,
}
func runGlob(cmd *cmdline.Command, args []string) error {
+ if len(args) == 1 {
+ args = append([]string{""}, args...)
+ }
if expected, got := 2, len(args); expected != got {
return cmd.UsageErrorf("glob: incorrect number of arguments, expected %d, got %d", expected, got)
}