OLD | NEW |
1 # Copyright (c) 2010 Google Inc. All rights reserved. | 1 # Copyright (c) 2010 Google Inc. All rights reserved. |
2 # Copyright (c) 2009 Apple Inc. All rights reserved. | 2 # Copyright (c) 2009 Apple Inc. All rights reserved. |
3 # | 3 # |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 PrintExpectations(), | 91 PrintExpectations(), |
92 Rebaseline(), | 92 Rebaseline(), |
93 RebaselineCL(), | 93 RebaselineCL(), |
94 RebaselineExpectations(), | 94 RebaselineExpectations(), |
95 RebaselineJson(), | 95 RebaselineJson(), |
96 RebaselineServer(), | 96 RebaselineServer(), |
97 RebaselineTest(), | 97 RebaselineTest(), |
98 ] | 98 ] |
99 self.help_command = HelpCommand() | 99 self.help_command = HelpCommand() |
100 self.commands.append(self.help_command) | 100 self.commands.append(self.help_command) |
101 # FIXME: Since tool is passed to Command.execute, it may not be necessar
y to set a tool attribute on the | |
102 # command objects here - maybe this should be done inside of Command.exe
cute for commands that use self._tool. | |
103 for command in self.commands: | |
104 command.bind_to_tool(self) | |
105 | 101 |
106 def main(self, argv=None): | 102 def main(self, argv=None): |
107 argv = argv or sys.argv | 103 argv = argv or sys.argv |
108 (command_name, args) = self._split_command_name_from_args(argv[1:]) | 104 (command_name, args) = self._split_command_name_from_args(argv[1:]) |
109 | 105 |
110 option_parser = self._create_option_parser() | 106 option_parser = self._create_option_parser() |
111 self._add_global_options(option_parser) | 107 self._add_global_options(option_parser) |
112 | 108 |
113 command = self.command_by_name(command_name) or self.help_command | 109 command = self.command_by_name(command_name) or self.help_command |
114 if not command: | 110 if not command: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 return False | 168 return False |
173 if command.requires_local_commits: | 169 if command.requires_local_commits: |
174 return self.scm().supports_local_commits() | 170 return self.scm().supports_local_commits() |
175 return True | 171 return True |
176 | 172 |
177 def command_by_name(self, command_name): | 173 def command_by_name(self, command_name): |
178 for command in self.commands: | 174 for command in self.commands: |
179 if command_name == command.name: | 175 if command_name == command.name: |
180 return command | 176 return command |
181 return None | 177 return None |
OLD | NEW |