/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: Canonical.com Patch Queue Manager
  • Date: 2007-09-03 07:34:25 UTC
  • mfrom: (2779.1.1 ianc-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070903073425-ouk9qod51gqk18nn
(Ian Clatworthy) Verbosity levels and standard options

Show diffs side-by-side

added added

removed removed

Lines of Context:
238
238
        """Construct an instance of this command."""
239
239
        if self.__doc__ == Command.__doc__:
240
240
            warn("No help message set for %r" % self)
 
241
        # List of standard options directly supported
 
242
        self.supported_std_options = []
241
243
 
242
244
    def _maybe_expand_globs(self, file_list):
243
245
        """Glob expand file_list if the platform does not do that itself.
417
419
        """Return dict of valid options for this command.
418
420
 
419
421
        Maps from long option name to option object."""
420
 
        r = dict()
421
 
        r['help'] = option._help_option
 
422
        r = Option.STD_OPTIONS.copy()
 
423
        std_names = r.keys()
422
424
        for o in self.takes_options:
423
425
            if isinstance(o, basestring):
424
426
                o = option.Option.OPTIONS[o]
425
427
            r[o.name] = o
 
428
            if o.name in std_names:
 
429
                self.supported_std_options.append(o.name)
426
430
        return r
427
431
 
428
432
    def _setup_outf(self):
458
462
                 DeprecationWarning, stacklevel=2)
459
463
            argv = []
460
464
        args, opts = parse_args(self, argv, alias_argv)
 
465
 
 
466
        # Process the standard options
461
467
        if 'help' in opts:  # e.g. bzr add --help
462
468
            sys.stdout.write(self.get_help_text())
463
469
            return 0
 
470
        trace.set_verbosity_level(option._verbosity_level)
 
471
        if 'verbose' in self.supported_std_options:
 
472
            opts['verbose'] = trace.is_verbose()
 
473
        elif opts.has_key('verbose'):
 
474
            del opts['verbose']
 
475
        if 'quiet' in self.supported_std_options:
 
476
            opts['quiet'] = trace.is_quiet()
 
477
        elif opts.has_key('quiet'):
 
478
            del opts['quiet']
 
479
 
464
480
        # mix arguments and options into one dictionary
465
481
        cmdargs = _match_argform(self.name(), self.takes_args, args)
466
482
        cmdopts = {}
691
707
            opt_no_aliases = True
692
708
        elif a == '--builtin':
693
709
            opt_builtin = True
694
 
        elif a in ('--quiet', '-q'):
695
 
            trace.be_quiet()
696
710
        elif a.startswith('-D'):
697
711
            debug.debug_flags.add(a[2:])
698
712
        else:
744
758
        return ret or 0
745
759
    finally:
746
760
        # reset, in case we may do other commands later within the same process
747
 
        trace.be_quiet(False)
 
761
        option._verbosity_level = 0
748
762
 
749
763
def display_command(func):
750
764
    """Decorator that suppresses pipe/interrupt errors."""