#  Copyright (c) 2015 Cisco Systems
#
#  Permission is hereby granted, free of charge, to any person obtaining a copy
#  of this software and associated documentation files (the "Software"), to deal
#  in the Software without restriction, including without limitation the rights
#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#  copies of the Software, and to permit persons to whom the Software is
#  furnished to do so, subject to the following conditions:
#
#  The above copyright notice and this permission notice shall be included in
#  all copies or substantial portions of the Software.
#
#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
#  THE SOFTWARE.
# """
# Usage:
#     molecule create      [--platform=<platform>] [--provider=<provider>] [--debug]
#     molecule converge    [--platform=<platform>] [--provider=<provider>] [--tags=<tag1,tag2>] [--debug]
#     molecule idempotence [--platform=<platform>] [--provider=<provider>] [--debug]
#     molecule test        [--platform=<platform>] [--provider=<provider>] [--debug]
#     molecule verify      [--platform=<platform>] [--provider=<provider>] [--debug]
#     molecule destroy     [--platform=<platform>] [--provider=<provider>] [--debug]
#     molecule status      [--platform=<platform>] [--provider=<provider>] [--debug]
#     molecule list        [--debug] [-m]
#     molecule login <host>
#     molecule init <role>
#     molecule -v | --version
#     molecule -h | --help

# Commands:
#     create       create instances
#     converge     create and provision instances
#     idempotence  converge and check the output for changes
#     test         run a full test cycle: destroy, create, converge, idempotency-check, verify and destroy instances
#     verify       create, provision and test instances
#     destroy      destroy instances
#     status       show status of instances
#     list         show available platforms, providers
#     login        connects to instance via SSH
#     init         creates the directory structure and files for a new Ansible role compatible with molecule

# Options:
#     -h --help              shows this screen
#     -v --version           shows the version
#     --platform=<platform>  specify a platform
#     --provider=<provider>  specify a provider
#     --tags=<tag1,tag2>     comma separated list of ansible tags to target
#     --debug                get more detail
#     -m                     machine readable output
# """
"""
Usage:
    molecule [-hv] <command> [<args>...]

Commands:
    create        create instances
    converge      create and provision instances
    idempotence   converge and check the output for changes
    test          run a full test cycle: destroy, create, converge, idempotency-check, verify and destroy instances
    verify        create, provision and test instances
    destroy       destroy instances
    status        show status of instances
    list          show available platforms, providers
    login         connects to instance via SSH
    init          creates the directory structure and files for a new Ansible role compatible with molecule

Options:
    -h --help     shows this screen
    -v --version  shows the version
"""

import sys

from docopt import docopt
from docopt import DocoptExit

import molecule
import molecule.commands


class CLI(object):
    def main(self):
        args = docopt(__doc__, version=molecule.__version__, options_first=True)
        command_name = args.get('<command>').capitalize()
        command_args = {} if args.get('<args>') is None else args.pop('<args>')

        try:
            command_class = getattr(molecule.commands, command_name)
        except AttributeError:
            raise DocoptExit()

        c = command_class(command_args, args)
        sys.exit(c.execute())


def main():
    CLI().main()


if __name__ == '__main__':
    main()

@@ -1105,1801 +1105,8 @@
 RE.%0A
-# %22%22%22%0A# Usage:%0A#     molecule create      %5B--platform=%3Cplatform%3E%5D %5B--provider=%3Cprovider%3E%5D %5B--debug%5D%0A#     molecule converge    %5B--platform=%3Cplatform%3E%5D %5B--provider=%3Cprovider%3E%5D %5B--tags=%3Ctag1,tag2%3E%5D %5B--debug%5D%0A#     molecule idempotence %5B--platform=%3Cplatform%3E%5D %5B--provider=%3Cprovider%3E%5D %5B--debug%5D%0A#     molecule test        %5B--platform=%3Cplatform%3E%5D %5B--provider=%3Cprovider%3E%5D %5B--debug%5D%0A#     molecule verify      %5B--platform=%3Cplatform%3E%5D %5B--provider=%3Cprovider%3E%5D %5B--debug%5D%0A#     molecule destroy     %5B--platform=%3Cplatform%3E%5D %5B--provider=%3Cprovider%3E%5D %5B--debug%5D%0A#     molecule status      %5B--platform=%3Cplatform%3E%5D %5B--provider=%3Cprovider%3E%5D %5B--debug%5D%0A#     molecule list        %5B--debug%5D %5B-m%5D%0A#     molecule login %3Chost%3E%0A#     molecule init %3Crole%3E%0A#     molecule -v %7C --version%0A#     molecule -h %7C --help%0A%0A# Commands:%0A#     create       create instances%0A#     converge     create and provision instances%0A#     idempotence  converge and check the output for changes%0A#     test         run a full test cycle: destroy, create, converge, idempotency-check, verify and destroy instances%0A#     verify       create, provision and test instances%0A#     destroy      destroy instances%0A#     status       show status of instances%0A#     list         show available platforms, providers%0A#     login        connects to instance via SSH%0A#     init         creates the directory structure and files for a new Ansible role compatible with molecule%0A%0A# Options:%0A#     -h --help              shows this screen%0A#     -v --version           shows the version%0A#     --platform=%3Cplatform%3E  specify a platform%0A#     --provider=%3Cprovider%3E  specify a provider%0A#     --tags=%3Ctag1,tag2%3E     comma separated list of ansible tags to target%0A#     --debug                get more detail%0A#     -m                     machine readable output%0A# %22%22%22%0A
 %22%22%22%0A

Remove commeted code. Fixes #76.