~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Robert Collins
  • Date: 2007-04-20 03:54:06 UTC
  • mto: This revision was merged to the branch mainline in revision 2441.
  • Revision ID: robertc@robertcollins.net-20070420035406-e68xf089otkpo7xx
Teach Command.get_help_text to show additional help cross references when supplied.

Show diffs side-by-side

added added

removed removed

Lines of Context:
260
260
        s = s[:-1]
261
261
        return s
262
262
 
263
 
    def get_help_text(self):
264
 
        """Return a text string with help for this command."""
 
263
    def get_help_text(self, additional_see_also=None):
 
264
        """Return a text string with help for this command.
 
265
        
 
266
        :param additional_see_also: Additional help topics to be
 
267
            cross-referenced.
 
268
        """
265
269
        doc = self.help()
266
270
        if doc is None:
267
271
            raise NotImplementedError("sorry, no detailed help yet for %r" % self.name())
285
289
            result += '\n'
286
290
        result += '\n'
287
291
        result += option.get_optparser(self.options()).format_option_help()
288
 
        see_also = self.get_see_also()
 
292
        see_also = self.get_see_also(additional_see_also)
289
293
        if see_also:
290
294
            result += '\nSee also: '
291
295
            result += ', '.join(see_also)
292
296
            result += '\n'
293
297
        return result
294
298
 
295
 
    def get_see_also(self):
 
299
    def get_see_also(self, additional_terms=None):
296
300
        """Return a list of help topics that are related to this ommand.
297
301
        
298
302
        The list is derived from the content of the _see_also attribute. Any
299
303
        duplicates are removed and the result is in lexical order.
 
304
        :param additional_terms: Additional help topics to cross-reference.
300
305
        :return: A list of help topics.
301
306
        """
302
 
        return sorted(set(getattr(self, '_see_also', [])))
 
307
        see_also = set(getattr(self, '_see_also', []))
 
308
        if additional_terms:
 
309
            see_also.update(additional_terms)
 
310
        return sorted(see_also)
303
311
 
304
312
    def options(self):
305
313
        """Return dict of valid options for this command.