feat: click cli
This commit is contained in:
10
main.py
10
main.py
@@ -1,5 +1,9 @@
|
||||
from jinja2 import Environment, FileSystemLoader, meta
|
||||
import click
|
||||
|
||||
@click.command()
|
||||
@click.option('--output', '-o', default='output.html', help='Name of Output File')
|
||||
def main(output):
|
||||
env = Environment(loader=FileSystemLoader('.'))
|
||||
filename = 'index.html'
|
||||
# get undeclared variables
|
||||
@@ -11,4 +15,8 @@ for var in vars:
|
||||
vars[var] = input(var+ ' :')
|
||||
# render template
|
||||
template = env.get_template(filename)
|
||||
print(template.render(vars))
|
||||
with open(output,'w') as out:
|
||||
out.write(template.render(vars))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user