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

Unified Diff: shell/subcmds/workon_cmd.py

Issue 6250058: Split out the big chromite shell 'main.py' into lots of subfiles. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/chromite.git@master
Patch Set: Incorporated davidjames and sosa feedback. Created 9 years, 11 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 | « shell/subcmds/shell_cmd.py ('k') | shell/utils.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: shell/subcmds/workon_cmd.py
diff --git a/shell/subcmds/workon_cmd.py b/shell/subcmds/workon_cmd.py
new file mode 100644
index 0000000000000000000000000000000000000000..dcebeab7b176539eee942681a7db65c751c34066
--- /dev/null
+++ b/shell/subcmds/workon_cmd.py
@@ -0,0 +1,42 @@
+# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Implementation of the 'workon' chromite command."""
+
+
+import chromite.lib.cros_build_lib as cros_lib
+from chromite.shell import subcmd
+
+
+class WorkonCmd(subcmd.WrappedChrootCmd):
+ """Run cros_workon."""
+
+ def __init__(self):
+ """WorkonCmd constructor."""
+ # Just call the WrappedChrootCmd superclass, which does most of the work.
+ # Note that host version uses "./", since it's in src/scripts and not in the
+ # path...
+ super(WorkonCmd, self).__init__(
+ ['cros_workon-%s'], ['./cros_workon', '--host'],
+ need_args=True
+ )
+
+ def Run(self, raw_argv, *args, **kwargs):
+ """Run the command.
+
+ We do just a slight optimization to help users with a common typo.
+
+ Args:
+ raw_argv: Command line arguments, including this command's name, but not
+ the chromite command name or chromite options.
+ args: The rest of the positional arguments. See _DoWrappedChrootCommand.
+ kwargs: The keyword arguments. See _DoWrappedChrootCommand.
+ """
+ # Slight optimization, just since I do this all the time...
+ if len(raw_argv) >= 2:
+ if raw_argv[1] in ('start', 'stop', 'list', 'list-all', 'iterate'):
+ cros_lib.Warning('OOPS, looks like you forgot a board name. Pick one.')
+ raw_argv = raw_argv[:1] + [''] + raw_argv[1:]
+
+ super(WorkonCmd, self).Run(raw_argv, *args, **kwargs)
« no previous file with comments | « shell/subcmds/shell_cmd.py ('k') | shell/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698