| OLD | NEW |
| 1 # Copyright (c) 2016 Google Inc. All rights reserved. | 1 # Copyright (c) 2016 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 argument_names = None | 43 argument_names = None |
| 44 long_help = None | 44 long_help = None |
| 45 | 45 |
| 46 def __init__(self, options=None, requires_local_commits=False): | 46 def __init__(self, options=None, requires_local_commits=False): |
| 47 self.required_arguments = self._parse_required_arguments(self.argument_n
ames) | 47 self.required_arguments = self._parse_required_arguments(self.argument_n
ames) |
| 48 self.options = options | 48 self.options = options |
| 49 self.requires_local_commits = requires_local_commits | 49 self.requires_local_commits = requires_local_commits |
| 50 self._tool = None | 50 self._tool = None |
| 51 # option_parser can be overridden by the tool using set_option_parser | 51 # option_parser can be overridden by the tool using set_option_parser |
| 52 # This default parser will be used for standalone_help printing. | 52 # This default parser will be used for standalone_help printing. |
| 53 self.option_parser = HelpPrintingOptionParser(usage=optparse.SUPPRESS_US
AGE, add_help_option=False, option_list=self.options) | 53 self.option_parser = HelpPrintingOptionParser( |
| 54 usage=optparse.SUPPRESS_USAGE, |
| 55 add_help_option=False, |
| 56 option_list=self.options) |
| 54 | 57 |
| 55 def _exit(self, code): | 58 def _exit(self, code): |
| 56 sys.exit(code) | 59 sys.exit(code) |
| 57 | 60 |
| 58 # This design is slightly awkward, but we need the | 61 # This design is slightly awkward, but we need the |
| 59 # the tool to be able to create and modify the option_parser | 62 # the tool to be able to create and modify the option_parser |
| 60 # before it knows what Command to run. | 63 # before it knows what Command to run. |
| 61 def set_option_parser(self, option_parser): | 64 def set_option_parser(self, option_parser): |
| 62 self.option_parser = option_parser | 65 self.option_parser = option_parser |
| 63 self._add_options_to_parser() | 66 self._add_options_to_parser() |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 # This method is overridden to add this one line to the output: | 147 # This method is overridden to add this one line to the output: |
| 145 error_message += "\nType \"%s --help\" to see usage.\n" % self.get_prog_
name() | 148 error_message += "\nType \"%s --help\" to see usage.\n" % self.get_prog_
name() |
| 146 self.exit(1, error_message) | 149 self.exit(1, error_message) |
| 147 | 150 |
| 148 # We override format_epilog to avoid the default formatting which would para
graph-wrap the epilog | 151 # We override format_epilog to avoid the default formatting which would para
graph-wrap the epilog |
| 149 # and also to allow us to compute the epilog lazily instead of in the constr
uctor (allowing it to be context sensitive). | 152 # and also to allow us to compute the epilog lazily instead of in the constr
uctor (allowing it to be context sensitive). |
| 150 def format_epilog(self, epilog): | 153 def format_epilog(self, epilog): |
| 151 if self.epilog_method: | 154 if self.epilog_method: |
| 152 return "\n%s\n" % self.epilog_method() | 155 return "\n%s\n" % self.epilog_method() |
| 153 return "" | 156 return "" |
| OLD | NEW |