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

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: Style and documentation 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 // The 'cr help' command. It is implemented here, rather than in the cmd/
6 // package, because it needs to be able to reference the other subcommands.
7
8 package main
9
10 import (
11 "flag"
12 "fmt"
13
14 "infra/tools/cr/lib/subcommand"
15 )
16
17 var shortHelp = "Print help for a subcommand."
18
19 var longHelp = `The help subcommand prints long-form help for the top-level cr c ommand
20 and its subcommands. Run 'cr help' for a list of available commands.
21
22 Examples:
23 cr help # print top-level help and list of commands
24 cr help firstrun # print help for the 'firstrun' subcommand
25 cr firstrun --help # same as above`
26
27 func helpRun(flags *flag.FlagSet) error {
28 if flags.NArg() == 0 {
29 printCrHelp()
30 return nil
31 }
32 helpcmd := subcommands[flags.Arg(0)]
seanmccullough1 2016/04/29 00:54:36 You could also say if helpcmd, ok := subcommands
agable 2016/05/05 23:59:43 Shiny, didn't know about that. Done.
33 if helpcmd == nil {
34 return fmt.Errorf("Unrecognized subcommand for help '%v'.\n", fl ags.Arg(0))
35 }
36 helpcmd.InitFlags(flags)
37 helpcmd.Help(flags)
38 return nil
39 }
40
41 var helpCmd = subcommand.New(shortHelp, longHelp, nil, helpRun)
seanmccullough1 2016/04/29 00:54:36 The existence of helpCmd here and helpcmd (lower c
agable 2016/05/05 23:59:43 Good idea, done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698