/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Jelmer Vernooij
  • Date: 2009-03-18 15:38:56 UTC
  • mfrom: (4163 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4164.
  • Revision ID: jelmer@samba.org-20090318153856-dr2lddyz56ajwb9c
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
 
51
51
from bzrlib import registry
52
52
# Compatibility
53
 
from bzrlib.hooks import Hooks
 
53
from bzrlib.hooks import HookPoint, Hooks
54
54
from bzrlib.option import Option
55
55
 
56
56
 
331
331
        return s
332
332
 
333
333
    def get_help_text(self, additional_see_also=None, plain=True,
334
 
                      see_also_as_links=False):
 
334
                      see_also_as_links=False, verbose=True):
335
335
        """Return a text string with help for this command.
336
336
 
337
337
        :param additional_see_also: Additional help topics to be
340
340
            returned instead of plain text.
341
341
        :param see_also_as_links: if True, convert items in 'See also'
342
342
            list to internal links (used by bzr_man rstx generator)
 
343
        :param verbose: if True, display the full help, otherwise
 
344
            leave out the descriptive sections and just display
 
345
            usage help (e.g. Purpose, Usage, Options) with a
 
346
            message explaining how to obtain full help.
343
347
        """
344
348
        doc = self.help()
345
349
        if doc is None:
374
378
            result += options
375
379
        result += '\n'
376
380
 
377
 
        # Add the description, indenting it 2 spaces
378
 
        # to match the indentation of the options
379
 
        if sections.has_key(None):
380
 
            text = sections.pop(None)
381
 
            text = '\n  '.join(text.splitlines())
382
 
            result += ':%s:\n  %s\n\n' % ('Description',text)
 
381
        if verbose:
 
382
            # Add the description, indenting it 2 spaces
 
383
            # to match the indentation of the options
 
384
            if sections.has_key(None):
 
385
                text = sections.pop(None)
 
386
                text = '\n  '.join(text.splitlines())
 
387
                result += ':%s:\n  %s\n\n' % ('Description',text)
383
388
 
384
 
        # Add the custom sections (e.g. Examples). Note that there's no need
385
 
        # to indent these as they must be indented already in the source.
386
 
        if sections:
387
 
            for label in order:
388
 
                if sections.has_key(label):
389
 
                    result += ':%s:\n%s\n\n' % (label,sections[label])
 
389
            # Add the custom sections (e.g. Examples). Note that there's no need
 
390
            # to indent these as they must be indented already in the source.
 
391
            if sections:
 
392
                for label in order:
 
393
                    if sections.has_key(label):
 
394
                        result += ':%s:\n%s\n' % (label,sections[label])
 
395
                result += '\n'
 
396
        else:
 
397
            result += ("See bzr help %s for more details and examples.\n\n"
 
398
                % self.name())
390
399
 
391
400
        # Add the aliases, source (plug-in) and see also links, if any
392
401
        if self.aliases:
523
532
        if 'help' in opts:  # e.g. bzr add --help
524
533
            sys.stdout.write(self.get_help_text())
525
534
            return 0
 
535
        if 'usage' in opts:  # e.g. bzr add --usage
 
536
            sys.stdout.write(self.get_help_text(verbose=False))
 
537
            return 0
526
538
        trace.set_verbosity_level(option._verbosity_level)
527
539
        if 'verbose' in self.supported_std_options:
528
540
            opts['verbose'] = trace.is_verbose()
591
603
        notified.
592
604
        """
593
605
        Hooks.__init__(self)
594
 
        # Introduced in 1.13:
595
 
        # invoked after creating a command object to allow modifications such
596
 
        # as adding or removing options, docs etc. Invoked with the command
597
 
        # object.
598
 
        self['extend_command'] = []
 
606
        self.create_hook(HookPoint('extend_command',
 
607
            "Called after creating a command object to allow modifications "
 
608
            "such as adding or removing options, docs etc. Called with the "
 
609
            "new bzrlib.commands.Command object.", (1, 13), None))
599
610
 
600
611
Command.hooks = CommandHooks()
601
612