Removed commandeer dependency.
h3rald h3rald@h3rald.com
Sun, 11 Jun 2017 16:22:08 +0200
2 files changed,
37 insertions(+),
54 deletions(-)
M
hastysite.nim
→
hastysite.nim
@@ -40,8 +40,6 @@ NoMetadataException* = ref Exception
DictionaryRequiredException* = ref Exception MetadataRequiredException* = ref Exception -setLogFilter(lvlNotice) - #### min Library proc hastysite_module*(i: In, hs: HastySite) =@@ -110,20 +108,6 @@ notice " - Copying: ", infile, " -> ", outfile
outfile.parentDir.createDir copyFileWithPermissions(infile, outfile) - def.symbol("content?") do (i: In): - var d: MinValue - i.reqDictionary d - let t = d.dget("type".newVal).getString - let r = t == "content" - i.push r.newVal - - def.symbol("asset?") do (i: In): - var d: MinValue - i.reqDictionary d - let t = d.dget("type".newVal).getString - let r = t == "asset" - i.push r.newVal - def.symbol("mustache") do (i: In): var t, c: MinValue i.reqQuotationAndString c, t@@ -205,12 +189,6 @@ return json[key].getStr
else: return default -proc confirmDeleteDir(hs: HastySite, dir: string): bool = - warn "Delete directory '$1' and all its contents? [Y/n] " % dir - var confirm = newString(1) - discard stdin.readChars(confirm, 0, 1) - return confirm == "\n" or confirm == "Y" or confirm == "y" - proc quitIfNotExists(file: string) = if not file.fileExists: quit("Error: File '$1' not found." % file)@@ -291,6 +269,7 @@ writeFile(dir/"settings.json", json.pretty)
proc clean*(hs: HastySite) = hs.dirs.temp.removeDir + hs.dirs.output.removeDir proc build*(hs: var HastySite) = notice "Preprocessing..."@@ -302,10 +281,11 @@
when isMainModule: import - packages/commandeer/commandeer + parseopt2 + + setLogFilter(lvlNotice) - proc usage(): string = - return """ $1 v$2 - a tiny static site generator + let usage = """ $1 v$2 - a tiny static site generator (c) 2016-2017 Fabio Cevasco Usage:@@ -319,30 +299,32 @@ Options:
-h, --help Print this help -v, --version Print the program version""" % [appname, version] - - - commandline: - argument command, string - exitoption "help", "h", usage() - exitoption "version", "v", version - errormsg usage() - let pwd = getCurrentDir() let cfg = pwd/"settings.json" - case command: - of "init": - pwd.init() - of "clean": - quitIfNotExists(cfg) - var hs = newHastySite(cfg) - if hs.confirmDeleteDir(hs.dirs.temp) and hs.confirmDeleteDir(hs.dirs.output): - hs.clean() + for kind, key, val in getopt(): + case kind: + of cmdArgument: + case key: + of "init": + pwd.init() + of "clean": + quitIfNotExists(cfg) + var hs = newHastySite(cfg) + hs.clean() + of "build": + quitIfNotExists(cfg) + var hs = newHastySite(cfg) + hs.clean() + hs.build() + of cmdLongOption, cmdShortOption: + case key: + of "help", "h": + echo usage + quit(0) + of "version", "v": + echo version + quit(0) + else: + discard else: - quit("Aborted.") - of "build": - quitIfNotExists(cfg) - var hs = newHastySite(cfg) - hs.clean() - hs.build() - else: - quit("Error: Command '$1' is not supported" % command) + discard
M
nifty.json
→
nifty.json
@@ -7,12 +7,18 @@ "cmd": "git clone {{src}} --depth 1"
}, "git+src+tag": { "cmd": "git clone --branch {{tag}} {{src}} --depth 1" + }, + "curl+src+name": { + "cmd": "curl {{src}} -o {{name}}" } }, "update": { "git+name": { "cmd": "git pull", "pwd": "{{name}}" + }, + "curl+src+name": { + "cmd": "curl {{src}} -o {{name}}" } } },@@ -26,11 +32,6 @@ "min": {
"name": "min", "git": true, "src": "https://github.com/h3rald/min.git" - }, - "commandeer": { - "name": "commandeer", - "src": "https://github.com/fenekku/commandeer.git", - "git": true }, "moustachu": { "name": "moustachu",