all repos — py-vite @ 33c876415042f8065b37772d981013b5b97cb3a8

the original vite, written in python

vite/cli.py (view raw)

 1import argparse
 2import os
 3import sys
 4from vite import vite
 5from huepy import *
 6from vite import __version__
 7
 8
 9def main():
10    desc = green('A simple and minimal static site generator.')
11    usage = lightblue('vite') + ' [options]'
12    parser = argparse.ArgumentParser(description=desc, usage=usage)
13    parser.add_argument('-v', '--version', action='version', version='{version}'.format(version=__version__))
14    sp = parser.add_subparsers(dest='cmd', help='Options to help create, build and serve your project.')
15    spp = sp.add_parser('new')
16    for cmd in ['build', 'serve']:
17        sp.add_parser(cmd)
18    spp.add_argument('path')
19    args = parser.parse_args()
20
21    if len(sys.argv) == 1:
22        parser.print_help()
23        sys.exit(1)
24    elif args.cmd == 'new':
25        if args.path:
26            vite.create_project(args.path)
27        else:
28            parser.print_help()
29    elif args.cmd == 'build':
30        vite.import_config()
31        vite.builder()
32    elif args.cmd == 'serve':
33        vite.import_config()
34        vite.server()
35    else:
36        parser.print_help()