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

Unified Diff: tools/cr/cr/commands/info.py

Issue 72723003: [cr tool] Adding the info command. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cr_main
Patch Set: Created 7 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/cr/cr/commands/info.py
diff --git a/tools/cr/cr/commands/info.py b/tools/cr/cr/commands/info.py
new file mode 100644
index 0000000000000000000000000000000000000000..12f2f63c4b02a7ec2ca5d48ee5177f5b92be5380
--- /dev/null
+++ b/tools/cr/cr/commands/info.py
@@ -0,0 +1,43 @@
+# Copyright (c) 2013 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.
+
+"""A module for the info implementation of Command."""
+
+import cr
+
+
+class InfoCommand(cr.Command):
+ """The cr info command implementation."""
+
+ def __init__(self):
+ super(InfoCommand, self).__init__()
+ self.help = 'Print information about the cr environment'
+
+ def AddArguments(self, subparsers):
+ parser = super(InfoCommand, self).AddArguments(subparsers)
+ parser.add_argument(
+ '-s', '--short', dest='_short',
+ action='store_true', default=False,
+ help='Short form results, useful for scripting.'
+ )
+ self.ConsumeArgs(parser, 'the environment')
+ return parser
+
+ def EarlyArgProcessing(self, context):
+ if getattr(context.args, '_short', False):
+ self.requires_build_dir = False
+
+ def Run(self, context):
+ if context.remains:
+ for var in context.remains:
+ if getattr(context.args, '_short', False):
+ val = context.Find(var)
+ if val is None:
+ val = ''
+ print val
+ else:
+ print var, '=', context.Find(var)
+ else:
+ cr.base.client.PrintInfo(context)
+
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698