diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-03-30 16:55:43 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-03-30 16:55:43 +0000 |
commit | 3225eca48f7ce16eb31b2dd5a170806c1214a49e (patch) | |
tree | 7e04d345c214f3efac3c4b86c7ec3e831c500437 /internal/lsp/cmd/subcommands.go | |
parent | 457aa020f87e3a763226dc76aa3459fd23d0aa11 (diff) | |
parent | f10932f763d058b0dcb3acfb795c869996fef47b (diff) | |
download | golang-x-tools-3225eca48f7ce16eb31b2dd5a170806c1214a49e.tar.gz |
Snap for 8383211 from f10932f763d058b0dcb3acfb795c869996fef47b to build-tools-release
Change-Id: I0969e0c20848f202469acc85c3681437b8b62fdc
Diffstat (limited to 'internal/lsp/cmd/subcommands.go')
-rw-r--r-- | internal/lsp/cmd/subcommands.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/internal/lsp/cmd/subcommands.go b/internal/lsp/cmd/subcommands.go index 5af5923b8..deac5c822 100644 --- a/internal/lsp/cmd/subcommands.go +++ b/internal/lsp/cmd/subcommands.go @@ -8,6 +8,7 @@ import ( "context" "flag" "fmt" + "text/tabwriter" "golang.org/x/tools/internal/tool" ) @@ -17,14 +18,16 @@ import ( type subcommands []tool.Application func (s subcommands) DetailedHelp(f *flag.FlagSet) { - fmt.Fprint(f.Output(), "\nsubcommands:\n") + w := tabwriter.NewWriter(f.Output(), 0, 0, 2, ' ', 0) + defer w.Flush() + fmt.Fprint(w, "\nSubcommand:\n") for _, c := range s { - fmt.Fprintf(f.Output(), " %s: %s\n", c.Name(), c.ShortHelp()) + fmt.Fprintf(w, " %s\t%s\n", c.Name(), c.ShortHelp()) } - f.PrintDefaults() + printFlagDefaults(f) } -func (s subcommands) Usage() string { return "<subcommand> [args...]" } +func (s subcommands) Usage() string { return "<subcommand> [arg]..." } func (s subcommands) Run(ctx context.Context, args ...string) error { if len(args) == 0 { @@ -33,7 +36,8 @@ func (s subcommands) Run(ctx context.Context, args ...string) error { command, args := args[0], args[1:] for _, c := range s { if c.Name() == command { - return tool.Run(ctx, c, args) + s := flag.NewFlagSet(c.Name(), flag.ExitOnError) + return tool.Run(ctx, s, c, args) } } return tool.CommandLineErrorf("unknown subcommand %v", command) |