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/root.go

Issue 1905233002: Add framework for basic 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
« no previous file with comments | « go/src/infra/tools/cr/cmd/firstrun.go ('k') | go/src/infra/tools/cr/main.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/tools/cr/cmd/root.go
diff --git a/go/src/infra/tools/cr/cmd/root.go b/go/src/infra/tools/cr/cmd/root.go
new file mode 100644
index 0000000000000000000000000000000000000000..c79e1655f8c465c0a17912f443d4d0ca1e85815d
--- /dev/null
+++ b/go/src/infra/tools/cr/cmd/root.go
@@ -0,0 +1,40 @@
+// 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 cmd
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/spf13/cobra"
+)
+
+// 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{
+ 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() {
+ if err := RootCmd.Execute(); err != nil {
+ fmt.Println(err)
+ os.Exit(-1)
+ }
+}
+
+func init() {
+ RootCmd.PersistentFlags().BoolP("verbose", "v", false, "Turn on verbose logging")
+}
« no previous file with comments | « go/src/infra/tools/cr/cmd/firstrun.go ('k') | go/src/infra/tools/cr/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698