diff options
author | petrcermak <petrcermak@chromium.org> | 2015-07-10 04:20:29 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-10 11:21:36 +0000 |
commit | bf2e95a7ac22ef45e47b7168f492d668d6b2415b (patch) | |
tree | e23561f9a46bab27261b9b1fd2b0c60dc826e07a /tools/cr | |
parent | e8827299809b21815936f3e652ba09ce48f6e7ea (diff) | |
download | chromium_src-bf2e95a7ac22ef45e47b7168f492d668d6b2415b.zip chromium_src-bf2e95a7ac22ef45e47b7168f492d668d6b2415b.tar.gz chromium_src-bf2e95a7ac22ef45e47b7168f492d668d6b2415b.tar.bz2 |
[cr] Add 'cr args' command
This patch adds an 'args' command to cr which opens the configuration
for the currently selected out directory in a text editor (similarly to
'gn args').
Review URL: https://codereview.chromium.org/1220523004
Cr-Commit-Position: refs/heads/master@{#338274}
Diffstat (limited to 'tools/cr')
-rw-r--r-- | tools/cr/cr/base/client.py | 7 | ||||
-rw-r--r-- | tools/cr/cr/commands/args.py | 32 |
2 files changed, 38 insertions, 1 deletions
diff --git a/tools/cr/cr/base/client.py b/tools/cr/cr/base/client.py index cb21222..4c89c46 100644 --- a/tools/cr/cr/base/client.py +++ b/tools/cr/cr/base/client.py @@ -218,7 +218,12 @@ def LoadConfig(): build_config_dir = _MigrateAndGetConfigDir(use_build_dir=True) cr.auto.build.__path__.append(build_config_dir) cr.loader.Scan() - return hasattr(cr.auto.build, 'config') + + if not hasattr(cr.auto.build, 'config'): + return False + + cr.context.derived.Set(CR_BUILD_CONFIG_PATH=_GetConfigFile(build_config_dir)) + return True def WriteConfig(use_build_dir, data): diff --git a/tools/cr/cr/commands/args.py b/tools/cr/cr/commands/args.py new file mode 100644 index 0000000..6427642 --- /dev/null +++ b/tools/cr/cr/commands/args.py @@ -0,0 +1,32 @@ +# Copyright 2015 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 args command.""" + +import os + +import cr + +class ArgsCommand(cr.Command): + """The implementation of the args command. + + The args command is meant for editing the current build configuration + in a text editor. + """ + + def __init__(self): + super(ArgsCommand, self).__init__() + self.help = 'Edit build configuration in a text editor' + self.description = (""" + Opens the configuration for the currently selected out directory in + a text editor. + """) + + def Run(self): + build_config_path = cr.context.Get('CR_BUILD_CONFIG_PATH') + editor = os.environ.get('EDITOR', 'vi') + print 'Opening %s in a text editor (%s)...' % (build_config_path, editor) + cr.Host.Execute(editor, build_config_path) + # TODO(petrcermak): Figure out a way to do this automatically. + print 'Please run \'cr prepare\' if you modified the file' |