satelito

Static [Web] Site (or Page) Generator (SSG) made with Lua script.
git clone git://soucy.cc/git/satelito.git
Log | Files | Refs | README

commit 082549b34ea1e84620d64789669c470c7b58964c
parent adaa8c0071b07b4bbfe17a474031a7dd52e25825
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Tue,  2 Feb 2021 16:54:49 -0500

Fix the argparse sequence

Diffstat:
Msatelito/init.lua | 39++++++++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/satelito/init.lua b/satelito/init.lua @@ -18,38 +18,55 @@ ** Template with etlua --]] --- -package.path = package.path .. ';'.. arg[0]:match("(.*/)") ..'/?.lua' --- - local argparse = require 'argparse' local assets = require 'satelito.assets' local feed = require 'satelito.feed' local file = require 'satelito.file' local inspect = require 'inspect' local page = require 'satelito.page' - local parser = argparse() + :require_command(false) :name 'satelito' :description 'Satelito is a static site generator in lua script.' :epilog 'For more info, see https://soucy.cc/git/satelito/file/README.md.html' +local init +local args -parser:argument('markdown filepath', 'The filepath to a markdown file'):args '?' -parser:flag('-e --export', 'Export the outputed HTML in your `public_html/` folder.') +parser:option('-f --file', 'Input a markdown filepath.'):args(1) +parser:flag('-p --pipeline', 'Input one or more markdown files through the pipeline.') +parser:flag('-e --export', 'Export the outputed HTML in the `paths.public_html` folder.') --parser:flag('-s --site', 'Explicitly process the content in site mode instead of the default page mode.') +parser:mutex( + parser:option('-f --file'), + parser:flag('-p --pipeline') +) -local args = parser:parse() +init = parser:command('init', 'Init the sample website in your $HOME.') +args = parser:parse() -if args['markdown filepath'] and file.is_markdown(args['markdown filepath']) then - local html, html_path = page.build(args['markdown filepath']) +if args['init'] then + os.execute('curl -s https://soucy.cc/satelito-sample.tar.gz -o ~/satelito-sample.tar.gz') + os.execute('tar -xvzf ~/satelito-sample.tar.gz -C ~/') + os.execute('ls -la ~/sample') + + print('-----------------------------------------------------------------------------------') + print('You shoul rename `~/sample` and edit `~/sample/config.lua` according to your needs.') +end + +if args['file'] and file.is_markdown(args['file']) then + local html, html_path = page.build(args['file']) if args['export'] then page.export(html_path, html) else print(html) end -else +end + +if args['pipeline'] then + print('Enter a filepath:') + -- for filepath in (io.lines()) do if file.is_markdown(filepath) then local html, html_path = page.build(filepath)