#!/usr/bin/env python
# Copyright 2013 Donald Stufft
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import, division, print_function

import argparse
import collections
import logging

import six

import twine.commands


logger = logging.getLogger(__name__)


class Twine(object):

    def cli(self, argv):
        def _generate_parser(parser, commands):
            # Generate our commands
            subparsers = parser.add_subparsers()
            for name, command in six.iteritems(commands):
                cmd_parser = subparsers.add_parser(name)

                if hasattr(command, "create_parser"):
                    command.create_parser(cmd_parser)

                if isinstance(command, collections.Mapping):
                    _generate_parser(cmd_parser, command)
                else:
                    cmd_parser.set_defaults(_cmd=command)

        parser = argparse.ArgumentParser(prog="twine")
        parser.add_argument(
            "-v", "--verbose",
            dest="_verbose",
            action="count",
            default=0,
        )
        parser.add_argument(
            "-q", "--quiet",
            dest="_quiet",
            action="store_true",
            default=False,
        )

        _generate_parser(parser, twine.commands.__commands__)

        args = parser.parse_args(argv)

        if getattr(args, "_cmd", None):
            return args._cmd(
                *args._get_args(),
                **{
                    k: v for k, v in args._get_kwargs()
                    if not k.startswith("_")
                }
            )
        else:
            parser.print_help()

@@ -703,16 +703,38 @@
  logging
+%0Aimport logging.config
 %0A%0Aimport
@@ -1871,16 +1871,803 @@
 (argv)%0A%0A
+        logging.config.dictConfig(%7B%0A            %22version%22: 1,%0A            %22disable_existing_loggers%22: False,%0A            %22formatters%22: %7B%0A                %22simple%22: %7B%0A                    %22format%22: %22%25(message)s%22,%0A                %7D,%0A            %7D,%0A            %22handlers%22: %7B%0A                %22console%22: %7B%0A                    %22level%22: %22DEBUG%22,%0A                    %22class%22: %22logging.StreamHandler%22,%0A                    %22formatter%22: %22simple%22,%0A                %7D,%0A            %7D,%0A            %22root%22: %7B%0A                %22level%22: logging.getLevelName(%0A                    max(%0A                        (30 - (args._verbose * 10)),%0A                        10,%0A                    ) if not args._quiet else %22CRITICAL%22%0A                ),%0A                %22handlers%22: %5B%22console%22%5D,%0A            %7D,%0A        %7D)%0A%0A
         

Use logging to control the output