remove manual main definitions
This commit is contained in:
@@ -1,2 +1 @@
|
|||||||
(function :Void main []
|
(print "Hello world!")
|
||||||
(print "Hello world!"))
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
(load "UtilMacros.kiss")
|
(load "UtilMacros.kiss")
|
||||||
(function :Void main []
|
|
||||||
(year 2018
|
(year 2018
|
||||||
(Solutions2018.run))
|
(Solutions2018.run))
|
||||||
(year 2020
|
(year 2020
|
||||||
(Solutions2020.run)))
|
(Solutions2020.run))
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
(function :Void main []
|
(print "Hello world!")
|
||||||
(print "Hello world!"))
|
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
(function :Void main []
|
(let [[jsonFile workingDir]
|
||||||
(let [[jsonFile workingDir]
|
(Sys.args)
|
||||||
(Sys.args)
|
json
|
||||||
json
|
(Json.parse
|
||||||
(Json.parse
|
(File.getContent (joinPath workingDir jsonFile)))
|
||||||
(File.getContent (joinPath workingDir jsonFile)))
|
oldVersion
|
||||||
oldVersion
|
json.version
|
||||||
json.version
|
:kiss.List<Int> versionParts
|
||||||
:kiss.List<Int> versionParts
|
(.map (oldVersion.split ".") Std.parseInt)]
|
||||||
(.map (oldVersion.split ".") Std.parseInt)]
|
(+= (nth versionParts -1) 1)
|
||||||
(+= (nth versionParts -1) 1)
|
(let [newVersion
|
||||||
(let [newVersion
|
(versionParts.join ".")]
|
||||||
(versionParts.join ".")]
|
(print "Bumping version of $jsonFile from $oldVersion -> $newVersion")
|
||||||
(print "Bumping version of $jsonFile from $oldVersion -> $newVersion")
|
(set json.version newVersion)
|
||||||
(set json.version newVersion)
|
(File.saveContent (joinPath workingDir jsonFile) (Json.stringify json "\t"))))
|
||||||
(File.saveContent (joinPath workingDir jsonFile) (Json.stringify json "\t")))))
|
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
|
// External programs can load Lib.kiss with (loadFrom "nat-archive-tool" "src/nat/Lib.kiss")
|
||||||
(load "Lib.kiss")
|
(load "Lib.kiss")
|
||||||
|
|
||||||
(function :Void main []
|
(let [[archiveDir] (Sys.args)
|
||||||
(let [[archiveDir] (Sys.args)
|
controller
|
||||||
controller
|
(new ArchiveController
|
||||||
(new ArchiveController
|
(new Archive archiveDir)
|
||||||
(new Archive archiveDir)
|
(new CLI))]
|
||||||
(new CLI))]
|
(loop
|
||||||
(loop
|
(Sys.print ">> ")
|
||||||
(Sys.print ">> ")
|
(let [command
|
||||||
(let [command
|
(.trim (.toString (.readLine (Sys.stdin))))]
|
||||||
(.trim (.toString (.readLine (Sys.stdin))))]
|
(if (controller.commands.exists command)
|
||||||
(if (controller.commands.exists command)
|
(controller.runCommand (dictGet controller.commands command))
|
||||||
(controller.runCommand (dictGet controller.commands command))
|
(Sys.println "$command is not a valid command")))))
|
||||||
(Sys.println "$command is not a valid command"))))))
|
|
||||||
|
|
||||||
(defNew [])
|
(defNew [])
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,30 @@
|
|||||||
// TODO external programs need to be able to find and (load) this path to get the macros:
|
// External programs can load Lib.kiss with (loadFrom "nat-archive-tool" "src/nat/Lib.kiss")
|
||||||
// ^ That should be solved by allowing an optional first argument to load that is a symbol
|
|
||||||
// of a library name that can be used to resolve the source dir in the user's Haxelib maybe?
|
|
||||||
(load "../nat/Lib.kiss")
|
(load "../nat/Lib.kiss")
|
||||||
|
|
||||||
|
(assert (BoolExpInterp.eval "true" []))
|
||||||
|
(assert !(BoolExpInterp.eval "false" []))
|
||||||
|
(assert !(BoolExpInterp.eval "flag" []))
|
||||||
|
(assert (BoolExpInterp.eval "flag" ["flag"]))
|
||||||
|
(assert !(BoolExpInterp.eval "(and flag false)" ["flag"]))
|
||||||
|
(assert (BoolExpInterp.eval "(or flag otherFlag)" ["otherFlag"]))
|
||||||
|
(let [archive
|
||||||
|
(new Archive "src/test/example-archive")
|
||||||
|
song1
|
||||||
|
(dictGet archive.entries "song1")
|
||||||
|
song2
|
||||||
|
(dictGet archive.entries "song2")]
|
||||||
|
|
||||||
(function :Void main []
|
(assert (hasComponent song1 Tags))
|
||||||
(assert (BoolExpInterp.eval "true" []))
|
(assert (hasComponent song2 Tags))
|
||||||
(assert !(BoolExpInterp.eval "false" []))
|
(assert (componentsMatch song1 "(and Name Author)"))
|
||||||
(assert !(BoolExpInterp.eval "flag" []))
|
(assert (componentsMatch song2 "(and Name Author)"))
|
||||||
(assert (BoolExpInterp.eval "flag" ["flag"]))
|
(assert (tagsMatch archive song1 "(and song western)"))
|
||||||
(assert !(BoolExpInterp.eval "(and flag false)" ["flag"]))
|
(assert !(tagsMatch archive song1 "(and song religious)"))
|
||||||
(assert (BoolExpInterp.eval "(or flag otherFlag)" ["otherFlag"]))
|
(assert (tagsMatch archive song2 "(and song religious)"))
|
||||||
//trace(error);
|
(assert !(tagsMatch archive song2 "(and song western)"))
|
||||||
(let [archive
|
|
||||||
(new Archive "src/test/example-archive")
|
|
||||||
song1
|
|
||||||
(dictGet archive.entries "song1")
|
|
||||||
song2
|
|
||||||
(dictGet archive.entries "song2")]
|
|
||||||
|
|
||||||
(assert (hasComponent song1 Tags))
|
(withWritableComponents archive song1
|
||||||
(assert (hasComponent song2 Tags))
|
[author Author
|
||||||
(assert (componentsMatch song1 "(and Name Author)"))
|
name Name]
|
||||||
(assert (componentsMatch song2 "(and Name Author)"))
|
(assert (= author "Rafael Krux"))
|
||||||
(assert (tagsMatch archive song1 "(and song western)"))
|
(assert (= name "Adventure"))))
|
||||||
(assert !(tagsMatch archive song1 "(and song religious)"))
|
|
||||||
(assert (tagsMatch archive song2 "(and song religious)"))
|
|
||||||
(assert !(tagsMatch archive song2 "(and song western)"))
|
|
||||||
|
|
||||||
(withWritableComponents archive song1
|
|
||||||
[author Author
|
|
||||||
name Name]
|
|
||||||
(assert (= author "Rafael Krux"))
|
|
||||||
(assert (= name "Adventure")))))
|
|
||||||
|
|||||||
@@ -13,16 +13,15 @@
|
|||||||
// TODO add sequentialPerPDF argument (which, when used, .shift()s pages from the beginning of PDFs)
|
// TODO add sequentialPerPDF argument (which, when used, .shift()s pages from the beginning of PDFs)
|
||||||
// TODO add chunkSize argument (default 1, which specifies how many pages in order to pull from a random PDF. value of -1 means take the whole PDF, and remove it from the list)
|
// TODO add chunkSize argument (default 1, which specifies how many pages in order to pull from a random PDF. value of -1 means take the whole PDF, and remove it from the list)
|
||||||
// TODO make output page limit optional
|
// TODO make output page limit optional
|
||||||
(function :Void main []
|
(let [[sourceDir numPages] (Sys.args)]
|
||||||
(let [[sourceDir numPages] (Sys.args)]
|
(loadAll (for file (Fs.readdirSync sourceDir) (+ sourceDir "/" file))
|
||||||
(loadAll (for file (Fs.readdirSync sourceDir) (+ sourceDir "/" file))
|
(lambda [:Array<PDFDocument> inputPdfs]
|
||||||
(lambda [:Array<PDFDocument> inputPdfs]
|
(awaitLet [saladPdf (PDFDocument.create)
|
||||||
(awaitLet [saladPdf (PDFDocument.create)
|
pages (Promise.all
|
||||||
pages (Promise.all
|
(for _ (range 0 (Std.parseInt numPages))
|
||||||
(for _ (range 0 (Std.parseInt numPages))
|
(let [:PDFDocument pdf (nth inputPdfs (Std.random inputPdfs.length))
|
||||||
(let [:PDFDocument pdf (nth inputPdfs (Std.random inputPdfs.length))
|
page (Std.random (pdf.getPageCount))]
|
||||||
page (Std.random (pdf.getPageCount))]
|
(saladPdf.copyPages pdf [page]))))]
|
||||||
(saladPdf.copyPages pdf [page]))))]
|
(doFor page pages (saladPdf.addPage (first page)))
|
||||||
(doFor page pages (saladPdf.addPage (first page)))
|
(awaitLet [bytesOut (saladPdf.save)]
|
||||||
(awaitLet [bytesOut (saladPdf.save)]
|
(Fs.writeFileSync "out.pdf" bytesOut))))))
|
||||||
(Fs.writeFileSync "out.pdf" bytesOut)))))))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user