OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 """Implementation of the 'workon' chromite command.""" |
| 6 |
| 7 |
| 8 import chromite.lib.cros_build_lib as cros_lib |
| 9 from chromite.shell import subcmd |
| 10 |
| 11 |
| 12 class WorkonCmd(subcmd.WrappedChrootCmd): |
| 13 """Run cros_workon.""" |
| 14 |
| 15 def __init__(self): |
| 16 """WorkonCmd constructor.""" |
| 17 # Just call the WrappedChrootCmd superclass, which does most of the work. |
| 18 # Note that host version uses "./", since it's in src/scripts and not in the |
| 19 # path... |
| 20 super(WorkonCmd, self).__init__( |
| 21 ['cros_workon-%s'], ['./cros_workon', '--host'], |
| 22 need_args=True |
| 23 ) |
| 24 |
| 25 def Run(self, raw_argv, *args, **kwargs): |
| 26 """Run the command. |
| 27 |
| 28 We do just a slight optimization to help users with a common typo. |
| 29 |
| 30 Args: |
| 31 raw_argv: Command line arguments, including this command's name, but not |
| 32 the chromite command name or chromite options. |
| 33 args: The rest of the positional arguments. See _DoWrappedChrootCommand. |
| 34 kwargs: The keyword arguments. See _DoWrappedChrootCommand. |
| 35 """ |
| 36 # Slight optimization, just since I do this all the time... |
| 37 if len(raw_argv) >= 2: |
| 38 if raw_argv[1] in ('start', 'stop', 'list', 'list-all', 'iterate'): |
| 39 cros_lib.Warning('OOPS, looks like you forgot a board name. Pick one.') |
| 40 raw_argv = raw_argv[:1] + [''] + raw_argv[1:] |
| 41 |
| 42 super(WorkonCmd, self).Run(raw_argv, *args, **kwargs) |
OLD | NEW |