completly set-up a package in the target dir (using cookie cutter)

def submain(p):
    """
    completly set-up a package in the target dir (using cookie cutter) 
        

    """
    parser = argparse.ArgumentParser(description='Bootstrap a Python Package with Love.')
    parser.add_argument('name', metavar='name', type=str, nargs='?',
                       help='a potential package name')
    parser.add_argument('target_dir', type=str, nargs='?',
                       help='target directory in which to create the package')
    parser.add_argument('--version', help='print version, logo and exist', action='store_true')
    parser.add_argument('--no-banner',  help='do not print banner', action='store_false')

    parser.add_argument('--no-travis', help='prevent Travis from being set-up', action='store_true')
    parser.add_argument('--no-flit', help='prevent usage of Flit to set-up-package', action='store_true')
    parser.add_argument('--no-similar', help='prevent search of similar project on PyPI', action='store_true')
    parser.add_argument('--python', help='set-up the minimal required python', action='store_true')

    args = parser.parse_args()
    proposal = args.name
    target_dir = args.target_dir
    

    LOGLEVEL = 50
    log = logging.getLogger(__name__)
    handler = logging.StreamHandler()
    handler.setFormatter(LogFormatter())
    logging.root.addHandler(handler)
    logging.root.setLevel(LOGLEVEL)
    log.setLevel(LOGLEVEL)

    log.info = withlog.glog

    if args.no_banner:
        p(cheart)
    if args.version : 
       p('Version : '+ __version__)
       sys.exit(0)

    if args.python :
        python_requires()
        sys.exit(0)

    if not target_dir:
        with Info('Target directory'):
            target_dir = os.getcwd()
            log.info('Will use target dir : %s', target_dir)



    # generate a python package name

    adjectives = ['red','green','blue','purple','fluffy','soft','hard','golden','silver', 'pathetic', 'intrepid', 'jovial' , 'long']
    nouns = ['moon', 'frog', 'lake','orchid','sapphire','gem','sun','lily','ocean','lampshade','fish', 'koala', 'shark', 'kangaroo']
    if proposal and not proposal.isidentifier() and len(proposal)>3:
        log.info('package names should be valid python identifiers, and at least 3 letters long : %s', proposal)
        sys.exit(-1)


    if not proposal:
        proposal = random.choice(adjectives).capitalize()+random.choice(nouns).capitalize()
    plist = None

    #  compare name with existing package name, warn if too close
    if not args.no_similar:
        with Info('Similar projects'):
            log.info('Comparing "%s" to other existing package names...' % proposal)
            pypi = pp.PyPIXmlRpc()
            # cache that on a weekly basis ?
            if plist is None:
                plist = pypi.list_packages()
            closest = difflib.get_close_matches(proposal.lower(), map(str.lower, plist), cutoff=0.8)
            if closest:
                if proposal in closest:
                    log.info(proposal + ' already exists, maybe you would prefer to contribute to this package?')
                else:
                    log.info('%s name is close to the following package name: %s', proposal,  closest)
                response = input('Do you still want to continue ? [Y/n]')
                if not response:
                    response = 'y'
                if not response.lower() == 'y':
                    sys.exit('Aborting')
            else:
                log.info('"%s" seems like a great name !', proposal)


    #  Actually authenticate with github 
    #  Create (if do not exist) the named repo, and  clone URL.
    with Info('Github'):
        token, user = setup_github_credentials(log=log)
        slug = setup_github_repository(user, proposal, log)
        
    os.chdir(proposal)
    log.debug('I am now in %s', os.getcwd())

    if not args.no_travis:
        with Info('Continuous Integration: Configuring Travis-CI'):
            enable_travis(token, slug, log) 

    with Info('Setting up Layout'):
        project_layout(proposal, None, None, log)

    if not args.no_flit:
        with Info('Setting up Package with Flit.') as p, withlog.print_statement(p), withlog.input():
            packaging_init(log)
            with Info('Python Minimal version') as p, withlog.print_statement(p):
                python_requires('>=3.4')
                p('Package marked as requiring python >= 3.4')