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

Unified Diff: go/src/infra/tools/cr/cmd/firstrun/firstrun.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, 8 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 side-by-side diff with in-line comments
Download patch
Index: go/src/infra/tools/cr/cmd/firstrun/firstrun.go
diff --git a/go/src/infra/tools/cr/cmd/firstrun/firstrun.go b/go/src/infra/tools/cr/cmd/firstrun/firstrun.go
new file mode 100644
index 0000000000000000000000000000000000000000..385ce1a72596931b539d0197a44b296f801ef6db
--- /dev/null
+++ b/go/src/infra/tools/cr/cmd/firstrun/firstrun.go
@@ -0,0 +1,44 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Package firstrun contains the logic for the 'cr firstrun' command.
+// Generally only executed once on a given machine, the firstrun command
+// installs the cr tool, prepares a space for it to install modules, and
+// adds it to $PATH.
+package firstrun
+
+import (
+ "flag"
+
+ "infra/tools/cr/lib/subcommand"
+)
+
+var (
+ // Package-level variables for subcommand flags.
+ path string
+)
+
+var shortHelp = "Install the cr tool and intelligently add it to $PATH."
+
+var longHelp = `Given a path to a desired install directory, it takes ownership of that
+directory, sets it up to support installation of modules, and adds the
+directory to $PATH (by prompting to modify e.g. the registry or .bashrc).
+
+The firstrun command is intended to only be run once, when first
+installing the cr tool.
seanmccullough1 2016/04/29 00:54:36 would "install" or "init" be a more obvious name t
agable 2016/05/05 23:59:42 Wanted to avoid "install", because that seems like
+
+Examples:
+ cr firstrun -verbose -path ~/local/bin/`
+
+func flags(flags *flag.FlagSet) {
+ flags.StringVar(&path, "path", "", "the path to install 'cr' in")
+}
+
+func run(flags *flag.FlagSet) error {
+ firstrunCheckNotInstalled()
seanmccullough1 2016/04/29 00:54:36 return firstrunCheckNotInstalled()?
agable 2016/05/05 23:59:42 Done.
+ return nil
+}
+
+// FirstrunCmd is a subcommand.Command representing the 'cr firstrun' command.
+var FirstrunCmd = subcommand.New(shortHelp, longHelp, flags, run)
« no previous file with comments | « no previous file | go/src/infra/tools/cr/cmd/firstrun/firstrun_nix.go » ('j') | go/src/infra/tools/cr/cmd/firstrun/firstrun_nix.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698