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

Side by Side Diff: tools/cr/cr/commands/info.py

Issue 142933004: [cr tool] Make context implicit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 9 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 unified diff | Download patch
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """A module for the info implementation of Command.""" 5 """A module for the info implementation of Command."""
6 6
7 import cr 7 import cr
8 8
9 9
10 class InfoCommand(cr.Command): 10 class InfoCommand(cr.Command):
11 """The cr info command implementation.""" 11 """The cr info command implementation."""
12 12
13 def __init__(self): 13 def __init__(self):
14 super(InfoCommand, self).__init__() 14 super(InfoCommand, self).__init__()
15 self.help = 'Print information about the cr environment' 15 self.help = 'Print information about the cr environment'
16 16
17 def AddArguments(self, subparsers): 17 def AddArguments(self, subparsers):
18 parser = super(InfoCommand, self).AddArguments(subparsers) 18 parser = super(InfoCommand, self).AddArguments(subparsers)
19 parser.add_argument( 19 parser.add_argument(
20 '-s', '--short', dest='_short', 20 '-s', '--short', dest='_short',
21 action='store_true', default=False, 21 action='store_true', default=False,
22 help='Short form results, useful for scripting.' 22 help='Short form results, useful for scripting.'
23 ) 23 )
24 self.ConsumeArgs(parser, 'the environment') 24 self.ConsumeArgs(parser, 'the environment')
25 return parser 25 return parser
26 26
27 def EarlyArgProcessing(self, context): 27 def EarlyArgProcessing(self):
28 if getattr(context.args, '_short', False): 28 if getattr(cr.context.args, '_short', False):
29 self.requires_build_dir = False 29 self.requires_build_dir = False
30 30
31 def Run(self, context): 31 def Run(self):
32 if context.remains: 32 if cr.context.remains:
33 for var in context.remains: 33 for var in cr.context.remains:
34 if getattr(context.args, '_short', False): 34 if getattr(cr.context.args, '_short', False):
35 val = context.Find(var) 35 val = cr.context.Find(var)
36 if val is None: 36 if val is None:
37 val = '' 37 val = ''
38 print val 38 print val
39 else: 39 else:
40 print var, '=', context.Find(var) 40 print var, '=', cr.context.Find(var)
41 else: 41 else:
42 cr.base.client.PrintInfo(context) 42 cr.base.client.PrintInfo()
43 43
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698