satelito

Static [web] site (or page) generator (ssg) made with Lua script.
git clone git://soucy.cc/satelito.git
Log | Files | Refs | README

commit b1d78ee89e45ac863a585fc6b287dbe8b1662135
parent 4c383923a227ac2954e9f1e8d0c03197d3a66313
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Thu,  1 Dec 2022 13:37:08 -0500

Start the purge command

Diffstat:
Msatelito/init.lua | 23++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/satelito/init.lua b/satelito/init.lua @@ -14,6 +14,7 @@ local init local pipe local make local exec +local purge local parser = argparse() :name 'satelito' @@ -30,8 +31,10 @@ pipe:flag('-e --export', 'Export the outputed HTML in the *config.paths.public_h make = parser:command('make', 'Build the site from his directory.') make:flag('-e --export', 'Export the outputed HTML in the *config.paths.public_html* folder.') -- Set the exec command -exec = parser:command('exec', 'Execute a script frome the bin directory') +exec = parser:command('exec', 'Execute a script from the bin directory.') exec:argument 'bin name' +-- Set the purge command +purge = parser:command('purge', 'Delete everything in the public_html directory.') args = parser:parse() @@ -145,9 +148,7 @@ end -- Make command -- Example: '$ satelito make --export' if args['make'] then - local config = _G.Satelito.config; local contentdir = _G.Satelito.contentdir - local templates = _G.Satelito.templates local sitedata = {} print('=> Fetching the markdown and HTML content ...') @@ -168,3 +169,19 @@ if args['make'] then return site.make(sitedata) end + +----------- +-- PURGE -- +----------- + +if args['purge'] then + local publicdir = _G.Satelito.publicdir + + for filepath in dirtree.get(publicdir) do + if file.get_basename(filepath) ~= '.gitignore' then + os.execute('rm -Rv '..filepath) + end + end + + print(os.clock()) +end