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

Unified Diff: go/src/infra/tools/cr/cmd/help/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, 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/help/help.go
diff --git a/go/src/infra/tools/cr/cmd/help/help.go b/go/src/infra/tools/cr/cmd/help/help.go
new file mode 100644
index 0000000000000000000000000000000000000000..5a7091be12b53c8f4a463a5d2f6a6f95ecfe9259
--- /dev/null
+++ b/go/src/infra/tools/cr/cmd/help/help.go
@@ -0,0 +1,42 @@
+// 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.
+
+/*
+Root command of the SDK; does most of the heavy lifting.
+*/
+
+package help
+
+import (
+ "os"
+)
+
+// Variables for flags which apply to all subcommands
+var verbose int
+
+// RootCmd is the root of the command tree. All subcommands attach to this one.
+// Also defines some persistent flags which are available to all subcommands.
+// Does not have a top-level Run function; instead just prints Usage.
+var RootCmd = &cobra.Command{
seanmccullough1 2016/04/29 00:54:36 where is cobra imported?
agable 2016/05/05 23:59:42 This whole file is gone (old patchset).
+ Use: "cr",
+ Short: "Entry point and module manager for the Chromium command-line SDK",
+ Long: `Entry point and module manager for the Chromium command-line SDK.
+
+Run "cr help", "cr help [command]", or "cr [command] --help" for documentation.`,
+}
+
+// Execute crawls the tree of commands (starting at RootCmd) to find the
+// appropriate function to execute. Prints usage is none is found.
+func Execute() {
+ ctx := context.Background()
+ ctx = gologger.StdConfig.Use(ctx)
+ if err := RootCmd.Execute(); err != nil {
+ logging.Errorf(ctx, "%v\n", err)
+ os.Exit(-1)
+ }
+}
+
+func init() {
+ RootCmd.PersistentFlags().CountVarP(&verbose, "verbose", "v", "Turn on verbose logging")
+}

Powered by Google App Engine
This is Rietveld 408576698