~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/option.py

  • Committer: John Arbash Meinel
  • Date: 2009-03-27 22:29:55 UTC
  • mto: (3735.39.2 clean)
  • mto: This revision was merged to the branch mainline in revision 4280.
  • Revision ID: john@arbash-meinel.com-20090327222955-utifmfm888zerixt
Implement apply_delta_to_source which doesn't have to malloc another string.

Show diffs side-by-side

added added

removed removed

Lines of Context:
150
150
    OPTIONS = {}
151
151
 
152
152
    def __init__(self, name, help='', type=None, argname=None,
153
 
                 short_name=None, param_name=None, custom_callback=None,
154
 
                 hidden=False):
 
153
                 short_name=None, param_name=None, custom_callback=None):
155
154
        """Make a new command option.
156
155
 
157
156
        :param name: regular name of the command, used in the double-dash
174
173
        :param custom_callback: a callback routine to be called after normal
175
174
            processing. The signature of the callback routine is
176
175
            (option, name, new_value, parser).
177
 
        :param hidden: If True, the option should be hidden in help and
178
 
            documentation.
179
176
        """
180
177
        self.name = name
181
178
        self.help = help
192
189
        else:
193
190
            self._param_name = param_name
194
191
        self.custom_callback = custom_callback
195
 
        self.hidden = hidden
196
192
 
197
193
    def short_name(self):
198
194
        if self._short_name:
212
208
        option_strings = ['--%s' % self.name]
213
209
        if short_name is not None:
214
210
            option_strings.append('-%s' % short_name)
215
 
        if self.hidden:
216
 
            help = optparse.SUPPRESS_HELP
217
 
        else:
218
 
            help = self.help
219
211
        optargfn = self.type
220
212
        if optargfn is None:
221
213
            parser.add_option(action='callback',
222
214
                              callback=self._optparse_bool_callback,
223
215
                              callback_args=(True,),
224
 
                              help=help,
 
216
                              help=self.help,
225
217
                              *option_strings)
226
218
            negation_strings = ['--%s' % self.get_negation_name()]
227
219
            parser.add_option(action='callback',
232
224
            parser.add_option(action='callback',
233
225
                              callback=self._optparse_callback,
234
226
                              type='string', metavar=self.argname.upper(),
235
 
                              help=help,
 
227
                              help=self.help,
236
228
                              default=OptionParser.DEFAULT_VALUE,
237
229
                              *option_strings)
238
230
 
258
250
        yield self.name, self.short_name(), argname, self.help
259
251
 
260
252
    def is_hidden(self, name):
261
 
        return self.hidden
 
253
        return False
262
254
 
263
255
 
264
256
class ListOption(Option):