all repos — py-vite @ 1efa6e0263169bfcf34cbbbd7fed158b66244255

the original vite, written in python

vite/cli.py (view raw)

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