ref: Add cmdline.HideGlobalFlagsExcept() to clean up help.

Closes: veyron/release-issue#1905

---------- Example of new output ----------
$ vrpc
ERROR: vrpc: no command specified

Command vrpc sends and receives Vanadium remote procedure calls.

Usage:
vrpc <command>

The vrpc commands are:
signature   Describe the interfaces of a Vanadium server
call        Call a method of a Vanadium server
identify    Reveal blessings presented by a Vanadium server
help        Display help for commands or topics
Run "vrpc help [command]" for command usage.

Run "vrpc help -style=full" to show all global flags.
----------

This CL shortens the default cmdline usage output, so that you
have a chance at seeing the important parts before it scrolls off
the screen.  The main culprit for long output is our long list of
global flags.

By default, nothing has changed; all global flags are shown in
usage.  Calling cmdline.HideGlobalFlagsExcept() causes the
default behavior to hide global flags, except for the given
regexps.  This mechanism was chosen since it seems better to have
global flags shown if the developer doesn't do anything special,
but if they call the method it's easier to specify a whitelist
than a blacklist.

To show all global flags you use "help -style=full", or set the
envvar CMDLINE_STYLE=full for root commands with no subcommands.
When any global flags are hidden, the usage includes a line
desribing the exact command to run to get the full output.

The -style=godoc output always shows all global flags.

MultiPart: 3/3

Change-Id: Ib397adf220489b251bd0b03badd0199c24c7d4a0
diff --git a/cmd/gclogs/gclogs.go b/cmd/gclogs/gclogs.go
index 9160287..76cb946 100644
--- a/cmd/gclogs/gclogs.go
+++ b/cmd/gclogs/gclogs.go
@@ -44,6 +44,7 @@
 )
 
 func init() {
+	cmdline.HideGlobalFlagsExcept()
 	cmdGCLogs.Flags.DurationVar(&flagCutoff, "cutoff", 24*time.Hour, "The age cut-off for a log file to be considered for garbage collection.")
 	cmdGCLogs.Flags.StringVar(&flagProgname, "program", ".*", `A regular expression to apply to the program part of the log file name, e.g ".*test".`)
 	cmdGCLogs.Flags.BoolVar(&flagVerbose, "verbose", false, "If true, each deleted file is shown on stdout.")
diff --git a/cmd/mounttable/doc.go b/cmd/mounttable/doc.go
index 7d653ee..562e14d 100644
--- a/cmd/mounttable/doc.go
+++ b/cmd/mounttable/doc.go
@@ -17,9 +17,11 @@
    unmount     removes server <name> from the mount table
    resolvestep takes the next step in resolving a name.
    help        Display help for commands or topics
-Run "mounttable help [command]" for command usage.
 
 The global flags are:
+ -v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
+   local namespace root; can be repeated to provided multiple roots
+
  -alsologtostderr=true
    log to standard error as well as files
  -log_backtrace_at=:0
@@ -38,8 +40,6 @@
    directory to use for storing security credentials
  -v23.i18n-catalogue=
    18n catalogue files to load, comma separated
- -v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
-   local namespace root; can be repeated to provided multiple roots
  -v23.proxy=
    object name of proxy service to use to export services across network
    boundaries
@@ -59,7 +59,7 @@
  -vmodule=
    comma-separated list of pattern=N settings for file-filtered logging
 
-Mounttable Glob
+Mounttable glob
 
 returns all matching entries in the mount table
 
@@ -70,7 +70,7 @@
 <pattern> is a glob pattern that is matched against all the entries below the
 specified mount name.
 
-Mounttable Mount
+Mounttable mount
 
 Mounts a server <name> onto a mount table
 
@@ -87,7 +87,7 @@
 [M|R] are mount options. M indicates that <name> is a mounttable. R indicates
 that existing entries should be removed.
 
-Mounttable Unmount
+Mounttable unmount
 
 removes server <name> from the mount table
 
@@ -97,7 +97,7 @@
 <mount name> is a mount name on a mount table. <name> is the rooted object name
 of the server.
 
-Mounttable Resolvestep
+Mounttable resolvestep
 
 takes the next step in resolving a name.
 
@@ -106,7 +106,7 @@
 
 <mount name> is a mount name on a mount table.
 
-Mounttable Help
+Mounttable help
 
 Help with no args displays the usage of the parent command.
 
@@ -114,11 +114,10 @@
 
 "help ..." recursively displays help for all commands and topics.
 
-The output is formatted to a target width in runes.  The target width is
-determined by checking the environment variable CMDLINE_WIDTH, falling back on
-the terminal width from the OS, falling back on 80 chars.  By setting
-CMDLINE_WIDTH=x, if x > 0 the width is x, if x < 0 the width is unlimited, and
-if x == 0 or is unset one of the fallbacks is used.
+Output is formatted to a target width in runes, determined by checking the
+CMDLINE_WIDTH environment variable, falling back on the terminal width, falling
+back on 80 chars.  By setting CMDLINE_WIDTH=x, if x > 0 the width is x, if x < 0
+the width is unlimited, and if x == 0 or is unset one of the fallbacks is used.
 
 Usage:
    mounttable help [flags] [command/topic ...]
@@ -126,7 +125,11 @@
 [command/topic ...] optionally identifies a specific sub-command or help topic.
 
 The mounttable help flags are:
- -style=default
-   The formatting style for help output, either "default" or "godoc".
+ -style=compact
+   The formatting style for help output:
+      compact - Good for compact cmdline output.
+      full    - Good for cmdline output, shows all global flags.
+      godoc   - Good for godoc processing.
+   Override the default by setting the CMDLINE_STYLE environment variable.
 */
 package main
diff --git a/cmd/mounttable/impl.go b/cmd/mounttable/impl.go
index 6b851e0..8be675e 100644
--- a/cmd/mounttable/impl.go
+++ b/cmd/mounttable/impl.go
@@ -7,6 +7,7 @@
 import (
 	"errors"
 	"fmt"
+	"regexp"
 	"time"
 
 	"v.io/v23"
@@ -15,11 +16,14 @@
 	"v.io/v23/options"
 	"v.io/v23/rpc"
 	"v.io/v23/security"
-
 	"v.io/x/lib/cmdline"
 	"v.io/x/lib/vlog"
 )
 
+func init() {
+	cmdline.HideGlobalFlagsExcept(regexp.MustCompile(`^v23\.namespace\.root$`))
+}
+
 var cmdGlob = &cmdline.Command{
 	Run:      runGlob,
 	Name:     "glob",
diff --git a/cmd/namespace/doc.go b/cmd/namespace/doc.go
index 9e25dbc..2f82af3 100644
--- a/cmd/namespace/doc.go
+++ b/cmd/namespace/doc.go
@@ -25,9 +25,11 @@
    permissions Manipulates permissions on an entry in the namespace
    delete      Deletes a name from the namespace
    help        Display help for commands or topics
-Run "namespace help [command]" for command usage.
 
 The global flags are:
+ -v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
+   local namespace root; can be repeated to provided multiple roots
+
  -alsologtostderr=true
    log to standard error as well as files
  -log_backtrace_at=:0
@@ -46,8 +48,6 @@
    directory to use for storing security credentials
  -v23.i18n-catalogue=
    18n catalogue files to load, comma separated
- -v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
-   local namespace root; can be repeated to provided multiple roots
  -v23.proxy=
    object name of proxy service to use to export services across network
    boundaries
@@ -67,7 +67,7 @@
  -vmodule=
    comma-separated list of pattern=N settings for file-filtered logging
 
-Namespace Glob
+Namespace glob
 
 Returns all matching entries from the namespace.
 
@@ -81,7 +81,7 @@
  -l=false
    Long listing format.
 
-Namespace Mount
+Namespace mount
 
 Adds server <server> to the namespace with name <name>.
 
@@ -93,7 +93,7 @@
 followed by a unit suffix (s, m, h). A value of 0s represents an infinite
 duration.
 
-Namespace Unmount
+Namespace unmount
 
 Removes server <server> with name <name> from the namespace.
 
@@ -103,7 +103,7 @@
 <name> is the name to remove from the namespace. <server> is the object address
 of the server to remove.
 
-Namespace Resolve
+Namespace resolve
 
 Translates a object name to its object address(es).
 
@@ -117,7 +117,7 @@
    Insecure mode: May return results from untrusted servers and invoke Resolve
    on untrusted mounttables
 
-Namespace Resolvetomt
+Namespace resolvetomt
 
 Finds the address of the mounttable that holds an object name.
 
@@ -131,7 +131,7 @@
    Insecure mode: May return results from untrusted servers and invoke Resolve
    on untrusted mounttables
 
-Namespace Permissions
+Namespace permissions
 
 Commands to get and set the permissions on a name - controlling the blessing
 names required to resolve the name.
@@ -146,7 +146,7 @@
    get         Gets permissions on a mount name
    set         Sets permissions on a mount name
 
-Namespace Permissions Get
+Namespace permissions get
 
 Get retrieves the permissions on the usage of a name.
 
@@ -158,7 +158,7 @@
 
 <name> is a name in the namespace.
 
-Namespace Permissions Set
+Namespace permissions set
 
 Set replaces the permissions controlling usage of a mount name.
 
@@ -170,7 +170,7 @@
 <permissions> is the path to a file containing a JSON-encoded Permissions object
 (defined in v.io/v23/security/access/types.vdl), or "-" for STDIN.
 
-Namespace Delete
+Namespace delete
 
 Deletes a name from the namespace.
 
@@ -183,7 +183,7 @@
  -r=false
    Delete all children of the name in addition to the name itself.
 
-Namespace Help
+Namespace help
 
 Help with no args displays the usage of the parent command.
 
@@ -191,11 +191,10 @@
 
 "help ..." recursively displays help for all commands and topics.
 
-The output is formatted to a target width in runes.  The target width is
-determined by checking the environment variable CMDLINE_WIDTH, falling back on
-the terminal width from the OS, falling back on 80 chars.  By setting
-CMDLINE_WIDTH=x, if x > 0 the width is x, if x < 0 the width is unlimited, and
-if x == 0 or is unset one of the fallbacks is used.
+Output is formatted to a target width in runes, determined by checking the
+CMDLINE_WIDTH environment variable, falling back on the terminal width, falling
+back on 80 chars.  By setting CMDLINE_WIDTH=x, if x > 0 the width is x, if x < 0
+the width is unlimited, and if x == 0 or is unset one of the fallbacks is used.
 
 Usage:
    namespace help [flags] [command/topic ...]
@@ -203,7 +202,11 @@
 [command/topic ...] optionally identifies a specific sub-command or help topic.
 
 The namespace help flags are:
- -style=default
-   The formatting style for help output, either "default" or "godoc".
+ -style=compact
+   The formatting style for help output:
+      compact - Good for compact cmdline output.
+      full    - Good for cmdline output, shows all global flags.
+      godoc   - Good for godoc processing.
+   Override the default by setting the CMDLINE_STYLE environment variable.
 */
 package main
diff --git a/cmd/namespace/impl.go b/cmd/namespace/impl.go
index 8f65e8e..9abaee2 100644
--- a/cmd/namespace/impl.go
+++ b/cmd/namespace/impl.go
@@ -8,6 +8,7 @@
 	"encoding/json"
 	"fmt"
 	"os"
+	"regexp"
 	"sort"
 	"time"
 
@@ -21,6 +22,10 @@
 	"v.io/x/lib/vlog"
 )
 
+func init() {
+	cmdline.HideGlobalFlagsExcept(regexp.MustCompile(`^v23\.namespace\.root$`))
+}
+
 var (
 	flagLongGlob            bool
 	flagInsecureResolve     bool
diff --git a/cmd/principal/doc.go b/cmd/principal/doc.go
index 6ce390d..84f6ef4 100644
--- a/cmd/principal/doc.go
+++ b/cmd/principal/doc.go
@@ -29,7 +29,6 @@
    addtoroots    Add to the set of identity providers recognized by this
                  principal
    help          Display help for commands or topics
-Run "principal help [command]" for command usage.
 
 The global flags are:
  -alsologtostderr=true
@@ -76,7 +75,7 @@
  -vmodule=
    comma-separated list of pattern=N settings for file-filtered logging
 
-Principal Create
+Principal create
 
 Creates a new principal with a single self-blessed blessing and writes it out to
 the provided directory. The same directory can then be used to set the
@@ -96,7 +95,7 @@
  -overwrite=false
    If true, any existing principal data in the directory will be overwritten
 
-Principal Fork
+Principal fork
 
 Creates a new principal with a blessing from the principal specified by the
 environment that this tool is running in, and writes it out to the provided
@@ -130,7 +129,7 @@
  -with=
    Path to file containing blessing to extend
 
-Principal Seekblessings
+Principal seekblessings
 
 Seeks blessings from a web-based Vanadium blesser which requires the caller to
 first authenticate with Google using OAuth. Simply run the command to see what
@@ -162,7 +161,7 @@
    If true, the blessings obtained will be set as the default blessing in the
    store
 
-Principal Recvblessings
+Principal recvblessings
 
 Allow another principal (likely a remote process) to bless this one.
 
@@ -213,7 +212,7 @@
    If true, the blessings received will be set as the default blessing in the
    store
 
-Principal Dump
+Principal dump
 
 Prints out information about the principal specified by the environment that
 this tool is running in.
@@ -225,7 +224,7 @@
  -s=false
    If true, show only the default blessing names
 
-Principal Dumpblessings
+Principal dumpblessings
 
 Prints out information about the blessings (typically obtained from this tool)
 encoded in the provided file.
@@ -236,7 +235,7 @@
 <file> is the path to a file containing blessings typically obtained from this
 tool. - is used for STDIN.
 
-Principal Blessself
+Principal blessself
 
 Returns a blessing with name <name> and self-signed by the principal specified
 by the environment that this tool is running in. Optionally, the blessing can be
@@ -256,7 +255,7 @@
  -for=0
    Duration of blessing validity (zero implies no expiration)
 
-Principal Bless
+Principal bless
 
 Bless another principal.
 
@@ -316,7 +315,7 @@
  -with=
    Path to file containing blessing to extend
 
-Principal Set
+Principal set
 
 Commands to mutate the blessings of the principal.
 
@@ -330,7 +329,7 @@
    default     Set provided blessings as default
    forpeer     Set provided blessings for peer
 
-Principal Set Default
+Principal set default
 
 Sets the provided blessings as default in the BlessingStore specified by the
 environment that this tool is running in.
@@ -349,7 +348,7 @@
    If true, the root certificate of the blessing will be added to the
    principal's set of recognized root certificates
 
-Principal Set Forpeer
+Principal set forpeer
 
 Marks the provided blessings to be shared with the provided peers on the
 BlessingStore specified by the environment that this tool is running in.
@@ -377,7 +376,7 @@
    If true, the root certificate of the blessing will be added to the
    principal's set of recognized root certificates
 
-Principal Get
+Principal get
 
 Commands to inspect the blessings of the principal.
 
@@ -394,7 +393,7 @@
    peermap         Shows the map from peer pattern to which blessing name to
                    present.
 
-Principal Get Default
+Principal get default
 
 Returns blessings that are marked as default in the BlessingStore specified by
 the environment that this tool is running in. Providing --names will print the
@@ -413,7 +412,7 @@
  -rootkey=
    Shows the value of the root key of the provided certificate chain name.
 
-Principal Get Forpeer
+Principal get forpeer
 
 Returns blessings that are marked for the provided peer in the BlessingStore
 specified by the environment that this tool is running in. Providing --names
@@ -438,7 +437,7 @@
  -rootkey=
    Shows the value of the root key of the provided certificate chain name.
 
-Principal Get Publickey
+Principal get publickey
 
 Prints out the public key of the principal specified by the environment that
 this tool is running in.
@@ -446,7 +445,7 @@
 Usage:
    principal get publickey
 
-Principal Get Recognizedroots
+Principal get recognizedroots
 
 Shows list of blessing names that the principal recognizes, and their associated
 public key. If the principal is operating as a client, contacted servers must
@@ -456,7 +455,7 @@
 Usage:
    principal get recognizedroots
 
-Principal Get Peermap
+Principal get peermap
 
 Shows the map from peer pattern to which blessing name to present. If the
 principal operates as a server, it presents its default blessing to all peers.
@@ -466,7 +465,7 @@
 Usage:
    principal get peermap
 
-Principal Addtoroots
+Principal addtoroots
 
 Adds an identity provider to the set of recognized roots public keys for this
 principal.
@@ -494,7 +493,7 @@
 
 <blessing pattern> is the blessing pattern for which <key> should be recognized.
 
-Principal Help
+Principal help
 
 Help with no args displays the usage of the parent command.
 
@@ -502,11 +501,10 @@
 
 "help ..." recursively displays help for all commands and topics.
 
-The output is formatted to a target width in runes.  The target width is
-determined by checking the environment variable CMDLINE_WIDTH, falling back on
-the terminal width from the OS, falling back on 80 chars.  By setting
-CMDLINE_WIDTH=x, if x > 0 the width is x, if x < 0 the width is unlimited, and
-if x == 0 or is unset one of the fallbacks is used.
+Output is formatted to a target width in runes, determined by checking the
+CMDLINE_WIDTH environment variable, falling back on the terminal width, falling
+back on 80 chars.  By setting CMDLINE_WIDTH=x, if x > 0 the width is x, if x < 0
+the width is unlimited, and if x == 0 or is unset one of the fallbacks is used.
 
 Usage:
    principal help [flags] [command/topic ...]
@@ -514,7 +512,11 @@
 [command/topic ...] optionally identifies a specific sub-command or help topic.
 
 The principal help flags are:
- -style=default
-   The formatting style for help output, either "default" or "godoc".
+ -style=compact
+   The formatting style for help output:
+      compact - Good for compact cmdline output.
+      full    - Good for cmdline output, shows all global flags.
+      godoc   - Good for godoc processing.
+   Override the default by setting the CMDLINE_STYLE environment variable.
 */
 package main
diff --git a/cmd/principal/main.go b/cmd/principal/main.go
index 8cdc55a..5585be0 100644
--- a/cmd/principal/main.go
+++ b/cmd/principal/main.go
@@ -873,6 +873,7 @@
 }
 
 func main() {
+	cmdline.HideGlobalFlagsExcept()
 	cmdBlessSelf.Flags.Var(&flagBlessSelfCaveats, "caveat", flagBlessSelfCaveats.usage())
 	cmdBlessSelf.Flags.DurationVar(&flagBlessSelfFor, "for", 0, "Duration of blessing validity (zero implies no expiration)")
 
diff --git a/cmd/uniqueid/doc.go b/cmd/uniqueid/doc.go
index c494452..9ad2e59 100644
--- a/cmd/uniqueid/doc.go
+++ b/cmd/uniqueid/doc.go
@@ -16,7 +16,6 @@
    generate    Generates UniqueIds
    inject      Injects UniqueIds into existing files
    help        Display help for commands or topics
-Run "uniqueid help [command]" for command usage.
 
 The global flags are:
  -alsologtostderr=true
@@ -63,14 +62,14 @@
  -vmodule=
    comma-separated list of pattern=N settings for file-filtered logging
 
-Uniqueid Generate
+Uniqueid generate
 
 Generates unique ids and outputs them to standard out.
 
 Usage:
    uniqueid generate
 
-Uniqueid Inject
+Uniqueid inject
 
 Injects UniqueIds into existing files. Strings of the form "$UNIQUEID$" will be
 replaced with generated ids.
@@ -80,7 +79,7 @@
 
 <filenames> List of files to inject unique ids into
 
-Uniqueid Help
+Uniqueid help
 
 Help with no args displays the usage of the parent command.
 
@@ -88,11 +87,10 @@
 
 "help ..." recursively displays help for all commands and topics.
 
-The output is formatted to a target width in runes.  The target width is
-determined by checking the environment variable CMDLINE_WIDTH, falling back on
-the terminal width from the OS, falling back on 80 chars.  By setting
-CMDLINE_WIDTH=x, if x > 0 the width is x, if x < 0 the width is unlimited, and
-if x == 0 or is unset one of the fallbacks is used.
+Output is formatted to a target width in runes, determined by checking the
+CMDLINE_WIDTH environment variable, falling back on the terminal width, falling
+back on 80 chars.  By setting CMDLINE_WIDTH=x, if x > 0 the width is x, if x < 0
+the width is unlimited, and if x == 0 or is unset one of the fallbacks is used.
 
 Usage:
    uniqueid help [flags] [command/topic ...]
@@ -100,7 +98,11 @@
 [command/topic ...] optionally identifies a specific sub-command or help topic.
 
 The uniqueid help flags are:
- -style=default
-   The formatting style for help output, either "default" or "godoc".
+ -style=compact
+   The formatting style for help output:
+      compact - Good for compact cmdline output.
+      full    - Good for cmdline output, shows all global flags.
+      godoc   - Good for godoc processing.
+   Override the default by setting the CMDLINE_STYLE environment variable.
 */
 package main
diff --git a/cmd/uniqueid/main.go b/cmd/uniqueid/main.go
index ca89740..9cd2737 100644
--- a/cmd/uniqueid/main.go
+++ b/cmd/uniqueid/main.go
@@ -21,6 +21,7 @@
 )
 
 func main() {
+	cmdline.HideGlobalFlagsExcept()
 	os.Exit(cmdUniqueId.Main())
 }
 
diff --git a/cmd/vdl/doc.go b/cmd/vdl/doc.go
index 7d12ec5..f51b087 100644
--- a/cmd/vdl/doc.go
+++ b/cmd/vdl/doc.go
@@ -18,14 +18,12 @@
    audit       Check if any packages are stale and need generation
    list        List package and dependency info in transitive order
    help        Display help for commands or topics
-Run "vdl help [command]" for command usage.
 
 The vdl additional help topics are:
    packages    Description of package lists
    vdlpath     Description of VDLPATH environment variable
    vdlroot     Description of VDLROOT environment variable
    vdl.config  Description of vdl.config files
-Run "vdl help [topic]" for topic details.
 
 The vdl flags are:
  -exts=.vdl
@@ -39,7 +37,7 @@
  -vdl.config=vdl.config
    Basename of the optional per-package config file.
 
-Vdl Generate
+Vdl generate
 
 Generate compiles packages and their transitive dependencies, and generates code
 in the specified languages.
@@ -93,7 +91,7 @@
  -status=true
    Show package names as they are updated
 
-Vdl Compile
+Vdl compile
 
 Compile compiles packages and their transitive dependencies, but does not
 generate code.  This is useful to sanity-check that your VDL files are valid.
@@ -108,7 +106,7 @@
  -status=true
    Show package names while we compile
 
-Vdl Audit
+Vdl audit
 
 Audit runs the same logic as generate, but doesn't write out generated files.
 Returns a 0 exit code if all packages are up-to-date, otherwise returns a non-0
@@ -163,7 +161,7 @@
  -status=true
    Show package names as they are updated
 
-Vdl List
+Vdl list
 
 List returns information about packages and their transitive dependencies, in
 transitive order.  This is the same order the generate and compile commands use
@@ -182,7 +180,7 @@
 <packages> are a list of packages to process, similar to the standard go tool.
 For more information, run "vdl help packages".
 
-Vdl Help
+Vdl help
 
 Help with no args displays the usage of the parent command.
 
@@ -190,11 +188,10 @@
 
 "help ..." recursively displays help for all commands and topics.
 
-The output is formatted to a target width in runes.  The target width is
-determined by checking the environment variable CMDLINE_WIDTH, falling back on
-the terminal width from the OS, falling back on 80 chars.  By setting
-CMDLINE_WIDTH=x, if x > 0 the width is x, if x < 0 the width is unlimited, and
-if x == 0 or is unset one of the fallbacks is used.
+Output is formatted to a target width in runes, determined by checking the
+CMDLINE_WIDTH environment variable, falling back on the terminal width, falling
+back on 80 chars.  By setting CMDLINE_WIDTH=x, if x > 0 the width is x, if x < 0
+the width is unlimited, and if x == 0 or is unset one of the fallbacks is used.
 
 Usage:
    vdl help [flags] [command/topic ...]
@@ -202,10 +199,14 @@
 [command/topic ...] optionally identifies a specific sub-command or help topic.
 
 The vdl help flags are:
- -style=default
-   The formatting style for help output, either "default" or "godoc".
+ -style=compact
+   The formatting style for help output:
+      compact - Good for compact cmdline output.
+      full    - Good for cmdline output, shows all global flags.
+      godoc   - Good for godoc processing.
+   Override the default by setting the CMDLINE_STYLE environment variable.
 
-Vdl Packages - help topic
+Vdl packages - help topic
 
 Most vdl commands apply to a list of packages:
 
@@ -233,7 +234,7 @@
  Run "vdl help vdlpath" to see docs on VDLPATH.
  Run "go help packages" to see the standard go package docs.
 
-Vdl Vdlpath - help topic
+Vdl vdlpath - help topic
 
 The VDLPATH environment variable is used to resolve import statements. It must
 be set to compile and generate vdl packages.
@@ -259,7 +260,7 @@
             baz/              (import "bar/baz" refers here)
                baz.vdl
 
-Vdl Vdlroot - help topic
+Vdl vdlroot - help topic
 
 The VDLROOT environment variable is similar to VDLPATH, but instead of pointing
 to multiple user source directories, it points at a single source directory
@@ -270,7 +271,7 @@
 If VDLROOT is empty, we try to construct it out of the V23_ROOT environment
 variable.  It is an error if both VDLROOT and V23_ROOT are empty.
 
-Vdl Vdl.Config - help topic
+Vdl vdl.config - help topic
 
 Each vdl source package P may contain an optional file "vdl.config" within the P
 directory.  This file specifies additional configuration for the vdl tool.
diff --git a/cmd/vom/doc.go b/cmd/vom/doc.go
index b25adef..4bdba37 100644
--- a/cmd/vom/doc.go
+++ b/cmd/vom/doc.go
@@ -15,7 +15,6 @@
    decode      Decode data encoded in the vom format
    dump        Dump data encoded in the vom format into formatted output
    help        Display help for commands or topics
-Run "vom help [command]" for command usage.
 
 The global flags are:
  -alsologtostderr=true
@@ -62,7 +61,7 @@
  -vmodule=
    comma-separated list of pattern=N settings for file-filtered logging
 
-Vom Decode
+Vom decode
 
 Decode decodes data encoded in the vom format.  If no arguments are provided,
 decode reads the data from stdin, otherwise the argument is the data.
@@ -80,7 +79,7 @@
  -data=Hex
    Data representation, one of [Hex Binary]
 
-Vom Dump
+Vom dump
 
 Dump dumps data encoded in the vom format, generating formatted output
 describing each portion of the encoding.  If no arguments are provided, dump
@@ -110,7 +109,7 @@
  -data=Hex
    Data representation, one of [Hex Binary]
 
-Vom Help
+Vom help
 
 Help with no args displays the usage of the parent command.
 
@@ -118,11 +117,10 @@
 
 "help ..." recursively displays help for all commands and topics.
 
-The output is formatted to a target width in runes.  The target width is
-determined by checking the environment variable CMDLINE_WIDTH, falling back on
-the terminal width from the OS, falling back on 80 chars.  By setting
-CMDLINE_WIDTH=x, if x > 0 the width is x, if x < 0 the width is unlimited, and
-if x == 0 or is unset one of the fallbacks is used.
+Output is formatted to a target width in runes, determined by checking the
+CMDLINE_WIDTH environment variable, falling back on the terminal width, falling
+back on 80 chars.  By setting CMDLINE_WIDTH=x, if x > 0 the width is x, if x < 0
+the width is unlimited, and if x == 0 or is unset one of the fallbacks is used.
 
 Usage:
    vom help [flags] [command/topic ...]
@@ -130,7 +128,11 @@
 [command/topic ...] optionally identifies a specific sub-command or help topic.
 
 The vom help flags are:
- -style=default
-   The formatting style for help output, either "default" or "godoc".
+ -style=compact
+   The formatting style for help output:
+      compact - Good for compact cmdline output.
+      full    - Good for cmdline output, shows all global flags.
+      godoc   - Good for godoc processing.
+   Override the default by setting the CMDLINE_STYLE environment variable.
 */
 package main
diff --git a/cmd/vom/vom.go b/cmd/vom/vom.go
index 16b5847..58d4fdc 100644
--- a/cmd/vom/vom.go
+++ b/cmd/vom/vom.go
@@ -25,6 +25,7 @@
 )
 
 func main() {
+	cmdline.HideGlobalFlagsExcept()
 	os.Exit(cmdVom.Main())
 }
 
diff --git a/cmd/vomtestgen/generate.go b/cmd/vomtestgen/generate.go
index cb53110..c4b67f9 100644
--- a/cmd/vomtestgen/generate.go
+++ b/cmd/vomtestgen/generate.go
@@ -62,6 +62,7 @@
 )
 
 func init() {
+	cmdline.HideGlobalFlagsExcept()
 	cmdGenerate.Flags.IntVar(&optGenMaxErrors, "max-errors", -1, "Stop processing after this many errors, or -1 for unlimited.")
 	cmdGenerate.Flags.StringVar(&optGenExts, "exts", ".vdl", "Comma-separated list of valid VDL file name extensions.")
 }
diff --git a/cmd/vrpc/doc.go b/cmd/vrpc/doc.go
index ff54449..aeaa638 100644
--- a/cmd/vrpc/doc.go
+++ b/cmd/vrpc/doc.go
@@ -17,9 +17,11 @@
    call        Call a method of a Vanadium server
    identify    Reveal blessings presented by a Vanadium server
    help        Display help for commands or topics
-Run "vrpc help [command]" for command usage.
 
 The global flags are:
+ -v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
+   local namespace root; can be repeated to provided multiple roots
+
  -alsologtostderr=true
    log to standard error as well as files
  -log_backtrace_at=:0
@@ -38,8 +40,6 @@
    directory to use for storing security credentials
  -v23.i18n-catalogue=
    18n catalogue files to load, comma separated
- -v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
-   local namespace root; can be repeated to provided multiple roots
  -v23.proxy=
    object name of proxy service to use to export services across network
    boundaries
@@ -59,7 +59,7 @@
  -vmodule=
    comma-separated list of pattern=N settings for file-filtered logging
 
-Vrpc Signature
+Vrpc signature
 
 Signature connects to the Vanadium server identified by <server>.
 
@@ -82,7 +82,7 @@
  -show-reserved=false
    if true, also show the signatures of reserved methods
 
-Vrpc Call
+Vrpc call
 
 Call connects to the Vanadium server identified by <server> and calls the
 <method> with the given positional [args...], returning results on stdout.
@@ -112,7 +112,7 @@
 
 [args...] are the positional input arguments, specified as VDL expressions.
 
-Vrpc Identify
+Vrpc identify
 
 Identify connects to the Vanadium server identified by <server> and dumps out
 the blessings presented by that server (and the subset of those that are
@@ -129,7 +129,7 @@
    If true, skip server authentication. This means that the client will reveal
    its blessings to servers that it may not recognize.
 
-Vrpc Help
+Vrpc help
 
 Help with no args displays the usage of the parent command.
 
@@ -137,11 +137,10 @@
 
 "help ..." recursively displays help for all commands and topics.
 
-The output is formatted to a target width in runes.  The target width is
-determined by checking the environment variable CMDLINE_WIDTH, falling back on
-the terminal width from the OS, falling back on 80 chars.  By setting
-CMDLINE_WIDTH=x, if x > 0 the width is x, if x < 0 the width is unlimited, and
-if x == 0 or is unset one of the fallbacks is used.
+Output is formatted to a target width in runes, determined by checking the
+CMDLINE_WIDTH environment variable, falling back on the terminal width, falling
+back on 80 chars.  By setting CMDLINE_WIDTH=x, if x > 0 the width is x, if x < 0
+the width is unlimited, and if x == 0 or is unset one of the fallbacks is used.
 
 Usage:
    vrpc help [flags] [command/topic ...]
@@ -149,7 +148,11 @@
 [command/topic ...] optionally identifies a specific sub-command or help topic.
 
 The vrpc help flags are:
- -style=default
-   The formatting style for help output, either "default" or "godoc".
+ -style=compact
+   The formatting style for help output:
+      compact - Good for compact cmdline output.
+      full    - Good for cmdline output, shows all global flags.
+      godoc   - Good for godoc processing.
+   Override the default by setting the CMDLINE_STYLE environment variable.
 */
 package main
diff --git a/cmd/vrpc/vrpc.go b/cmd/vrpc/vrpc.go
index 590e02d..e540707 100644
--- a/cmd/vrpc/vrpc.go
+++ b/cmd/vrpc/vrpc.go
@@ -11,6 +11,7 @@
 	"fmt"
 	"io"
 	"os"
+	"regexp"
 	"strings"
 	"time"
 
@@ -37,6 +38,7 @@
 )
 
 func main() {
+	cmdline.HideGlobalFlagsExcept(regexp.MustCompile(`^v23\.namespace\.root$`))
 	var shutdown v23.Shutdown
 	gctx, shutdown = v23.Init()
 	exitCode := cmdVRPC.Main()
diff --git a/cmd/vrun/vrun.go b/cmd/vrun/vrun.go
index cdfde06..92f707f 100644
--- a/cmd/vrun/vrun.go
+++ b/cmd/vrun/vrun.go
@@ -42,6 +42,7 @@
 }
 
 func main() {
+	cmdline.HideGlobalFlagsExcept()
 	syscall.CloseOnExec(3)
 	syscall.CloseOnExec(4)