diff --git a/pythonbrew/__init__.py b/pythonbrew/__init__.py index 26fd0f4..5e2f4d8 100644 --- a/pythonbrew/__init__.py +++ b/pythonbrew/__init__.py @@ -15,4 +15,4 @@ def main(): parser.error("Unknown command: `%s`" % command) return command = command_dict[command] - command.run(args) + command.run(args[1:]) diff --git a/pythonbrew/basecommand.py b/pythonbrew/basecommand.py index 437b12d..64692b2 100644 --- a/pythonbrew/basecommand.py +++ b/pythonbrew/basecommand.py @@ -18,7 +18,7 @@ class Command(object): def run(self, args): options, args = self.parser.parse_args(args) - self.run_command(options, args[1:]) + self.run_command(options, args) def load_command(name): full_name = 'pythonbrew.commands.%s' % name diff --git a/pythonbrew/commands/py.py b/pythonbrew/commands/py.py index 78de2bc..17f724f 100644 --- a/pythonbrew/commands/py.py +++ b/pythonbrew/commands/py.py @@ -28,35 +28,27 @@ class PyCommand(Command): default=False, help="Show the running python version." ) - self.parser.add_option( - "-b", "--bin", - dest="bin", - default='python', - help="Use the specified script in python's bin directory." - ) - self.parser.add_option( - "-o", "--options", - dest="options", - default='', - help="Options passed directly to runs script." - ) + self.parser.disable_interspersed_args() def run_command(self, options, args): if not args: logger.info("Unrecognized command line argument: argument not found.") sys.exit(1) - python_file = args[0] - pythons = self._get_pythons(options.pythons) for d in pythons: - path = os.path.join(PATH_PYTHONS, d, 'bin', options.bin) + if options.verbose: + logger.info('*** %s ***' % d) + path = os.path.join(PATH_PYTHONS, d, 'bin', args[0]) if os.path.isfile(path) and os.access(path, os.X_OK): - if options.verbose: - logger.info('*** %s ***' % d) - p = Popen("%s %s %s" % (path, options.options, python_file), shell=True) + p = Popen("%s %s" % (path, ' '.join(args[1:])), shell=True) p.wait() else: - logger.info('%s: No such file or directory.' % path) + path = os.path.join(PATH_PYTHONS, d, 'bin', 'python') + if os.path.isfile(path) and os.access(path, os.X_OK): + p = Popen("%s %s" % (path, ' '.join(args)), shell=True) + p.wait() + else: + logger.info('%s: No such file or directory.' % path) def _get_pythons(self, _pythons): pythons = [Package(p).name for p in _pythons]