Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Side by Side Diff: go/src/infra/tools/cr/help.go

Issue 1929153002: Add beginnings of new cr command (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698