def __init__(self, root_dir, parser, argv): Command.__init__(self, root_dir, parser, argv) if len(self.args) is not 1: self.error("Exactly one BUILD address is required.") spec = self.args[0] try: address = Address.parse(root_dir, spec) except IOError: self.error("Problem parsing spec %s: %s" % (spec, traceback.format_exc())) try: self.target = Target.get(address) except (ImportError, SyntaxError, TypeError): self.error("Problem parsing BUILD target %s: %s" % (address, traceback.format_exc())) if not self.target: self.error("Target %s does not exist" % address)
def _synthesize_command(root_dir, args): command = args[0] if command in Command.all_commands(): subcommand_args = args[1:] if len(args) > 1 else [] return command, _add_default_options(command, subcommand_args) if command.startswith('-'): _exit_and_fail('Invalid command: %s' % command) # assume 'build' if a command was omitted. try: Address.parse(root_dir, command) return _BUILD_COMMAND, _add_default_options(_BUILD_COMMAND, args) except: _exit_and_fail('Failed to execute pants build: %s' % traceback.format_exc())
def __init__(self, root_dir, parser, args): self.targets = [] Command.__init__(self, root_dir, parser, args)
def __init__(self, root_dir, parser, args): self.targets = [] # Note that we can't gate this on the self.options.time flag, because self.options is # only set up in Command.__init__, and only after it calls setup_parser(), which uses the timer. self.timer = Timer() Command.__init__(self, root_dir, parser, args)
def __init__(self, run_tracker, root_dir, parser, args): self.targets = [] Command.__init__(self, run_tracker, root_dir, parser, args)
def _find_all_commands(): for cmd in Command.all_commands(): cls = Command.get_command(cmd) yield '%s\t%s' % (cmd, cls.__doc__)
def _parse_command(root_dir, args): command, args = _synthesize_command(root_dir, args) return Command.get_command(command), args