| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /* |
| 6 The 'cr help' command. It is implemented here, rather than in the cmd/ package, |
| 7 because it needs to be able to enumerate and reference the other subcommands. |
| 8 */ |
| 9 |
| 10 package main |
| 11 |
| 12 import ( |
| 13 "flag" |
| 14 "fmt" |
| 15 |
| 16 "infra/tools/cr/lib/subcommand" |
| 17 ) |
| 18 |
| 19 var shortHelp = "Print help for a subcommand." |
| 20 |
| 21 var longHelp = `The help subcommand prints long-form help for the top-level cr c
ommand |
| 22 and its subcommands. Run 'cr help' for a list of available commands. |
| 23 |
| 24 Examples: |
| 25 cr help # print top-level help and list of commands |
| 26 cr help firstrun # print help for the 'firstrun' subcommand |
| 27 cr firstrun --help # same as above` |
| 28 |
| 29 func helpRun(flags *flag.FlagSet) error { |
| 30 if flags.NArg() == 0 { |
| 31 printCrHelp() |
| 32 return nil |
| 33 } |
| 34 helpcmd := subcommands[flags.Arg(0)] |
| 35 if helpcmd == nil { |
| 36 return fmt.Errorf("Unrecognized subcommand for help '%v'.\n", fl
ags.Arg(0)) |
| 37 } |
| 38 helpcmd.InitFlags(flags) |
| 39 helpcmd.Help(flags) |
| 40 return nil |
| 41 } |
| 42 |
| 43 var helpCmd = subcommand.New(shortHelp, longHelp, nil, helpRun) |
| OLD | NEW |