all repos — py-vite @ b41def3aca3b7a981faaea67b5aae1d1487462bc

the original vite, written in python

refactor(make.py): move argument parsing to main func
Anirudh icyph0x@pm.me
Tue, 17 Apr 2018 21:26:25 +0530
commit

b41def3aca3b7a981faaea67b5aae1d1487462bc

parent

937a9493f40b8830e65a7e83f63797ac4d71e580

1 files changed, 25 insertions(+), 26 deletions(-)

jump to
M make.pymake.py

@@ -12,32 +12,6 @@ from markdown2 import markdown_path

from huepy import * from distutils.dir_util import copy_tree -desc = green('Script to build and serve Vite projects.') -usage = lightblue('make.py') + ' [serve]' -help_txt = 'Serve pages from the ' + italic('build') + ' directory.' -parser = argparse.ArgumentParser(description=desc, usage=usage) -parser.add_argument('serve', nargs='*', help=help_txt) - -args = parser.parse_args() - -# import config file -try: - sys.path.append(os.getcwd()) - import config -except ModuleNotFoundError: - print(bad('Error: config.py not found.')) - print(que('Are you sure you\'re in a project directory?')) - parser.print_help() - sys.exit(1) - -# constants -PAGES_PATH = 'pages/' -BUILD_PATH = 'build/' -TEMPL_PATH = 'templates/' -TEMPL_FILE = TEMPL_PATH + config.template -PORT = 1911 - - # jinja2 def jinja_render(html_text, TEMPL_FILE): template_loader = jinja2.FileSystemLoader('./')

@@ -103,4 +77,29 @@ print(bad('Error: specified template not found: %s' % TEMPL_FILE))

if __name__ == "__main__": + desc = green('Script to build and serve Vite projects.') + usage = lightblue('make.py') + ' [serve]' + help_txt = 'Serve pages from the ' + italic('build') + ' directory.' + parser = argparse.ArgumentParser(description=desc, usage=usage) + parser.add_argument('serve', nargs='*', help=help_txt) + + args = parser.parse_args() + + # import config file + try: + sys.path.append(os.getcwd()) + import config + except ModuleNotFoundError: + print(bad('Error: config.py not found.')) + print(que('Are you sure you\'re in a project directory?')) + parser.print_help() + sys.exit(1) + + # constants + PAGES_PATH = 'pages/' + BUILD_PATH = 'build/' + TEMPL_PATH = 'templates/' + TEMPL_FILE = TEMPL_PATH + config.template + PORT = 1911 + main()