ferron

Ferron is a fast and simple static website generator made with Lua.
Log | Files | Refs | Submodules | README | LICENSE

commit 02f78031ca87c8f3fde41642b2ef73b073ff68b0
parent d5ffc3fb38daaf3a55eee5f5c5970708dbf3ac07
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Tue, 10 Apr 2018 07:29:56 -0400

Continue the CLI.

Diffstat:
Mcornelius | 18++++++++++--------
Mferron.lua | 8++++----
Mferron/content.lua | 15++++++++++-----
Mferron/site.lua | 2+-
4 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/cornelius b/cornelius @@ -2,6 +2,11 @@ -- Cornelius Ferron is the CLI of Ferron SSG and it's a WIP. -- <https://en.wikipedia.org/wiki/Cornelius_the_First> + +-- Commands : +-- ./cornelius install - Install ferron and his dependencies +-- ./cornelius build [--dev] - Build your site in prod or dev +-- ./cornelius create - Create content from archetypes local config = require "config" if arg[1] == "install" and tonumber(_VERSION:match("%d+%.%d+")) >= config.dependencies.lua then @@ -15,17 +20,14 @@ if arg[1] == "install" and tonumber(_VERSION:match("%d+%.%d+")) >= config.depend print("Ferron needs Luarocks for installing his dependencies.") print("Please install it on your system https://luarocks.org/.") end + elseif arg[1] == "build" and arg[2] == "--dev" then os.execute("lua -l ferron.setpaths ferron.lua --dev") elseif arg[1] == "build" then os.execute("lua -l ferron.setpaths ferron.lua") elseif arg[1] == "create" then - os.execute("lua -l ferron.setpaths ferron.lua --set archetype") + os.execute("lua -l ferron.setpaths ferron.lua --set content") +else + print("Hi, I'm Cornelius Ferron, the eminence of the great horn of the static site generator... or if you prefer, the CLI.") + print("What Can I Do for You?") end - --- install - install ferron and his dependencies --- build - build site in prod or dev --- create (TODO) - create content from archetypes --- -- 1) set site --- -- 2) choose an archetype from the selected site --- -- 3) create the content from the chosen archetype diff --git a/ferron.lua b/ferron.lua @@ -40,8 +40,8 @@ Ferron.build = { static.move } -if arg[1] == "--set" and arg[2] == "archetype" then - return content.setarchetype(site.setsite()) -else - return exec(Ferron.init, Ferron.build) +if arg[1] == "--set" and arg[2] == "content" then + return content.setcontent(site.setsite()) end + +return exec(Ferron.init, Ferron.build) diff --git a/ferron/content.lua b/ferron/content.lua @@ -28,9 +28,10 @@ function content.getarchetypes(dir) end end -function content.setarchetype(site) +function content.setcontent(site) local archetypes = content.getarchetypes(site.path .. site.siteconfig.paths.archetypes) - local whicharchetype = 0 + local whicharchetype = nil + local whichtitle = nil repeat io.write("Which archetypes do you need to complete your request? \n") @@ -45,10 +46,14 @@ function content.setarchetype(site) whicharchetype=io.read() until (tableutils.haskey(archetypes, tonumber(whicharchetype))) == true - print(inspect(archetypes[tonumber(whicharchetype)])) + repeat + io.write("Please write the title of your new content... \n") + io.flush() + + whichtitle=io.read() + until (type(tostring(whichtitle))) == "string" - -- return archetypes[tonumber(whicharchetype)] - return content.makecontent(archetypes[tonumber(whicharchetype)], "TEST de création") + return content.makecontent(archetypes[tonumber(whicharchetype)], tostring(whichtitle)) end function content.makecontent(contenttype, contenttitle) diff --git a/ferron/site.lua b/ferron/site.lua @@ -36,7 +36,7 @@ function site.setsite() local whichsite = nil repeat - io.write("Welcome to Ferron! Which site do you want to build? \n") + io.write("For which website do you want to proceed? \n") for k, v in ipairs(sites_arr) do io.write(k .. ") " .. v .. "\n")