vite/cli.py (view raw)
1import argparse
2import os
3import sys
4from vite import vite
5from huepy import *
6
7
8def main():
9 desc = green('A simple and minimal static site generator.')
10 usage = lightblue('vite') + ' [new | build | serve]'
11 # parser = argparse.ArgumentParser(description=desc, usage=usage)
12 parser = argparse.ArgumentParser()
13 # help_text = 'Commands to create, build and serve your project.'
14 sp = parser.add_subparsers(dest='cmd')
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.builder()
31 elif args.cmd == 'serve':
32 vite.server()
33 else:
34 parser.print_help()