Exemplo n.º 1
0
def main():
    if len(sys.argv) == 1:
        print_usage()
    else:
        arg = sys.argv[1]

    if arg == '-f' or arg == '--file':
        if len(sys.argv) >= 3:
            fileName = sys.argv[2]
        else:
            fileName = raw_input("Enter Filename: ")
        make_new_from_template(fileName)
        sys.exit(0)

    elif arg == '-d' or arg == '--dir':
        if len(sys.argv) >= 3:
            dirName = sys.argv[2]
        else:
            dirName = raw_input("Enter Dir name: ")
        make_dir(dirName)
        os.chdir(dirName)
        make_init_py()
        os.chdir('../')
        print 'made directory: {0}'.format(dirName)
        sys.exit(0)

    elif arg == '-n' or arg == '--new':
        if len(sys.argv) < 3:
            print_usage()
        else:
            projectName = sys.argv[2]
            make_project(projectName)

    else:
        print_usage()
Exemplo n.º 2
0
def main():
    templateType = False

    if len(sys.argv) == 1:
        print_usage()
    else:
        arg = sys.argv[1]

    if arg == '-f' or arg == '--file':
        if len(sys.argv) >= 3:
            fileName = sys.argv[2]
            if len(sys.argv) >= 4:
                if sys.argv[3].lower() == '-t' or sys.argv[3] == '--template-type':
                    templateType = sys.argv[4]
        else:
            fileName = raw_input("Enter Filename: ")
        if templateType:
            make_new_from_template(fileName, templateType)
        else:
            make_new_from_template(fileName) # allow for second argument here for template type, optional
        #sys.exit(0)

    elif arg == '-d' or arg == '--dir':
        if len(sys.argv) >= 3:
            dirName = sys.argv[2]
        else:
            dirName = raw_input("Enter Dir name: ")
	try:
       	    make_dir(dirName)
            os.chdir(dirName)
            make_init_py()
            os.chdir('../')
            print 'made directory: {0}'.format(dirName)
        except:
	    print 'Im in {}'.format(commands.getoutput('pwd'))
	    os.rmdir(dirName)
	    sys.exit(0)

    elif arg == '-n' or arg == '--new':
        if len(sys.argv) < 3:
            print_usage()
        else:
            projectName = sys.argv[2]
            make_project(projectName)

    else:
        print_usage()
Exemplo n.º 3
0
def make_project(name):
    make_dir(name)
    os.chdir(name)
    make_new_from_template(name)
    make_init_py()
    init_git()