<commit_before>'''
usage:
    paradrop login
    paradrop register
    paradrop install <host> <port> <path-to-config> 
    paradrop delete <host> <port> <chute-name>
    paradrop start <host> <port> <chute-name>
    paradrop stop <host> <port> <chute-name>
    paradrop snap-install <host> <port>
    paradrop router-create
    paradrop router-provision <name> <host> <port>
    paradrop list
    paradrop logs <name>
    paradrop echo <host> <port>
    paradrop (-h | --help)
    paradrop --version

options:
    -h --help     Show this screen.
    --version     Show version.

The most commonly used paradrop commands are:
   add        Add file contents to the index
   branch     List, create, or delete branches
   checkout   Checkout a branch or paths to the working tree
   clone      Clone a repository into a new directory
   commit     Record changes to the repository
   push       Update remote refs along with associated objects
   remote     Manage set of tracked repositories

See 'paradrop help <command>' for more information on a specific command.
'''

from pkg_resources import get_distribution

from docopt import docopt
from twisted.internet import task
from twisted.internet import reactor

from pdtools.lib import output, riffle, names
from pdtools.coms import routers, general, server
from pdtools.lib.store import store

# SERVER_HOST = 'paradrop.io'
SERVER_HOST = 'localhost'
SERVER_PORT = 8015


def main():
    # For now, don't grab STDIO and don't write random log noise to conosle
    output.out.startLogging(stealStdio=False, printToConsole=False)

    # show the documentation and extract host and port if provided (since they are commonly used)
    args = docopt(__doc__, version=get_distribution('pdtools').version)
    host, port = args['<host>'], args['<port>']
    port = int(port) if port else None

    # Initialize riffle with default values (can be overridden later)
    riffle.portal.certCa = store.getKey('ca.pem')
    riffle.portal.keyPrivate = store.getKey('client.pem')
    riffle.portal.host = SERVER_HOST
    # NOTE: riffle serves on its own default port. This is a different port from the const above

    # Register realms. See riffle documentation for Realm in pdtools.lib.riffle
    riffle.portal.addRealm(names.matchers[names.NameTypes.server], riffle.Realm(server.ServerPerspective))
    riffle.portal.addRealm(names.matchers[names.NameTypes.router], riffle.Realm(riffle.RifflePerspective))

    # Make it happen.
    if args['install']:
        return routers.installChute(args['<host>'], args['<port>'], args['<path-to-config>'])

    if args['delete']:
        return routers.deleteChute(args['<host>'], args['<port>'], args['<chute-name>'])

    if args['start']:
        return routers.startChute(args['<host>'], args['<port>'], args['<chute-name>'])

    if args['stop']:
        return routers.stopChute(args['<host>'], args['<port>'], args['<chute-name>'])

    if args['snap-install']:
        print 'Not implemented. Sorry, love.'

    if args['login']:
        task.react(server.login)

    if args['register']:
        task.react(server.register)

    # logged in calls
    if not store.loggedIn():
        print 'You must login first.'
        return

    if args['logs']:
        reactor.callLater(.1, server.logs, None, args['<name>'])
        reactor.run()
        return

    if args['echo']:
        task.react(general.echo, (host, port))

    if args['list']:
        task.react(server.list)

    if args['router-create']:
        task.react(general.test)

    if args['router-provision']:
        task.react(routers.provisionRouter, (args['<name>'], args['<host>'], args['<port>']))

    print 'Something broke'

if __name__ == '__main__':
    main()
<commit_msg>new docs on tools<commit_after>'''
usage:
    paradrop login
    paradrop register
    paradrop install <host> <port> <path-to-config> 
    paradrop delete <host> <port> <chute-name>
    paradrop start <host> <port> <chute-name>
    paradrop stop <host> <port> <chute-name>
    paradrop snap-install <host> <port>
    paradrop router-create
    paradrop router-provision <name> <host> <port>
    paradrop list
    paradrop logs <name>
    paradrop echo <host> <port>
    paradrop (-h | --help)
    paradrop --version

options:
    -h --help     Show this screen.
    --version     Show version.
'''

from pkg_resources import get_distribution

from docopt import docopt
from twisted.internet import task
from twisted.internet import reactor

from pdtools.lib import output, riffle, names
from pdtools.coms import routers, general, server
from pdtools.lib.store import store

# SERVER_HOST = 'paradrop.io'
SERVER_HOST = 'localhost'
SERVER_PORT = 8015


def main():
    # show the documentation and extract host and port if provided (since they are commonly used)
    args = docopt(__doc__, version=get_distribution('pdtools').version)
    host, port = args['<host>'], args['<port>']
    port = int(port) if port else None

    setup()

    # Make it happen.
    if args['install']:
        return routers.installChute(args['<host>'], args['<port>'], args['<path-to-config>'])

    if args['delete']:
        return routers.deleteChute(args['<host>'], args['<port>'], args['<chute-name>'])

    if args['start']:
        return routers.startChute(args['<host>'], args['<port>'], args['<chute-name>'])

    if args['stop']:
        return routers.stopChute(args['<host>'], args['<port>'], args['<chute-name>'])

    if args['snap-install']:
        print 'Not implemented. Sorry, love.'

    if args['login']:
        task.react(server.login)

    if args['register']:
        task.react(server.register)

    # logged in calls
    if not store.loggedIn():
        print 'You must login first.'
        return

    if args['logs']:
        reactor.callLater(.1, server.logs, None, args['<name>'])
        reactor.run()
        return

    if args['echo']:
        task.react(general.echo, (host, port))

    if args['list']:
        task.react(server.list)

    if args['router-create']:
        task.react(general.test)

    if args['router-provision']:
        task.react(routers.provisionRouter, (args['<name>'], args['<host>'], args['<port>']))

    print 'Something broke'


def setup():
    '''
    Boilerplate setup. Start the logger, give riffle crypto keys, and 
    initialize riffle's portal by creating name to realm assignments
    '''
    # For now, don't grab STDIO and don't write random log noise to conosle
    output.out.startLogging(stealStdio=False, printToConsole=False)

    # Initialize riffle with default values (can be overridden later)
    riffle.portal.certCa = store.getKey('ca.pem')
    riffle.portal.keyPrivate = store.getKey('client.pem')
    riffle.portal.host = SERVER_HOST
    # NOTE: riffle serves on its own default port. This is a different port from the const above

    # Register realms. See riffle documentation for Realm in pdtools.lib.riffle
    riffle.portal.addRealm(names.matchers[names.NameTypes.server], riffle.Realm(server.ServerPerspective))
    riffle.portal.addRealm(names.matchers[names.NameTypes.router], riffle.Realm(riffle.RifflePerspective))


###################################################################
# New Docs (currently incomplete)
###################################################################

rootDoc = """
usage: git [--version] [--exec-path=<path>] [--html-path]
           [-p|--paginate|--no-pager] [--no-replace-objects]
           [--bare] [--git-dir=<path>] [--work-tree=<path>]
           [-c <name>=<value>] [--help]
           <command> [<args>...]

options:
   -c <name=value>
   -h, --help
   -p, --paginate

The most commonly used git commands are:
   add        Add file contents to the index
   branch     List, create, or delete branches
   checkout   Checkout a branch or paths to the working tree
   clone      Clone a repository into a new directory
   commit     Record changes to the repository
   push       Update remote refs along with associated objects
   remote     Manage set of tracked repositories

See 'git help <command>' for more information on a specific command.

"""
routerDoc = """
usage: paradrop router provision
       paradrop router list

    -v, --verbose         be verbose; must be placed before a subcommand

Other Content!
    Look!
"""


def routerMenu(argv):
    args = docopt(routerDoc)
    print args


def main2():
    ''' Show documentation and branch appropriately '''
    # show the documentation and extract host and port if provided (since they are commonly used)
    args = docopt(rootDoc, version=get_distribution('pdtools').version)

    # host, port = args['<host>'], args['<port>']
    # port = int(port) if port else None
    argv = [args['<command>']] + args['<args>']

    if args['<command>'] == 'remote':
        # routerMenu(argv)
        args = docopt(routerDoc)
        print args


if __name__ == '__main__':
    main()

{'fraction_non_alphanumeric': 0.14112495789828225, 'fraction_numerical': 0.0012349837206691366, 'mean_word_length': 3.27447216890595, 'pattern_counts': {'":': 0, '<': 94, '<?xml version=': 0, '>': 94, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3675516', 'n_tokens_mistral': 2784, 'n_tokens_neox': 2730, 'n_words': 807}