Chromium Code Reviews| 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 // Package firstrun contains the logic for the 'cr firstrun' command. | |
| 6 // Generally only executed once on a given machine, the firstrun command | |
| 7 // installs the cr tool, prepares a space for it to install modules, and | |
| 8 // adds it to $PATH. | |
| 9 package firstrun | |
| 10 | |
| 11 import ( | |
| 12 "flag" | |
| 13 | |
| 14 "infra/tools/cr/lib/subcommand" | |
| 15 ) | |
| 16 | |
| 17 var ( | |
| 18 // Package-level variables for subcommand flags. | |
| 19 path string | |
| 20 ) | |
| 21 | |
| 22 var shortHelp = "Install the cr tool and intelligently add it to $PATH." | |
| 23 | |
| 24 var longHelp = `Given a path to a desired install directory, it takes ownership of that | |
| 25 directory, sets it up to support installation of modules, and adds the | |
| 26 directory to $PATH (by prompting to modify e.g. the registry or .bashrc). | |
| 27 | |
| 28 The firstrun command is intended to only be run once, when first | |
| 29 installing the cr tool. | |
| 30 | |
| 31 Examples: | |
| 32 cr firstrun -verbose -path ~/local/bin/` | |
| 33 | |
| 34 func flags(flags *flag.FlagSet) { | |
| 35 flags.StringVar(&path, "path", "", "the path to install 'cr' in") | |
| 36 } | |
| 37 | |
| 38 func run(flags *flag.FlagSet) error { | |
| 39 firstrunCheckNotInstalled() | |
|
seanmccullough1
2016/05/06 00:43:54
What do you think of having stubbable funcs return
agable
2016/05/10 00:34:10
Yep, great idea. They now return errors.
| |
| 40 return nil | |
| 41 } | |
| 42 | |
| 43 // FirstrunCmd is a subcommand.Command representing the 'cr firstrun' command. | |
| 44 var FirstrunCmd = subcommand.New("firstrun", shortHelp, longHelp, flags, run) | |
| OLD | NEW |