diff --git a/projects/nat-archive-tool/haxelib.json b/projects/nat-archive-tool/haxelib.json index 82b73518..0f11a0d4 100644 --- a/projects/nat-archive-tool/haxelib.json +++ b/projects/nat-archive-tool/haxelib.json @@ -8,6 +8,7 @@ "releasenote": "It isn't safe to use this library yet.", "contributors": ["NQNStudios"], "classPath": "src/", + "main": "nat.CLI", "dependencies": { "kiss": "", "tink_json": "" diff --git a/projects/nat-archive-tool/src/nat/Archive.kiss b/projects/nat-archive-tool/src/nat/Archive.kiss index a6c7236e..d2ce20eb 100644 --- a/projects/nat-archive-tool/src/nat/Archive.kiss +++ b/projects/nat-archive-tool/src/nat/Archive.kiss @@ -30,6 +30,8 @@ (Path.join [archiveDir "entries" (e.id.withExtension "json")]) (Json.stringify e))) +// TODO adding or removing components or files should save the Entry and re-check it in or out of systems + (defun :Entry _newEntry [] (object id (Uuid.v4) diff --git a/projects/nat-archive-tool/src/nat/ArchiveController.hx b/projects/nat-archive-tool/src/nat/ArchiveController.hx new file mode 100644 index 00000000..9499f56c --- /dev/null +++ b/projects/nat-archive-tool/src/nat/ArchiveController.hx @@ -0,0 +1,26 @@ +package nat; + +import kiss.Prelude; +import kiss.List; +import kiss.Operand; + +import haxe.Constraints; + +enum CommandArgument { + SelectedEntry; + SelectedEntries(min:Null, max:Null); + Text(minLength:Null, maxLength:Null); + Number(min:Null, max:Null, inStepsOf:Null); + Entry; + Entries(min:Null, max:Null); +} + +typedef Command = { + args:Array, + handler:Function +}; + +typedef ChangeSet = Array; + +@:build(kiss.Kiss.build()) +class ArchiveController {} diff --git a/projects/nat-archive-tool/src/nat/ArchiveController.kiss b/projects/nat-archive-tool/src/nat/ArchiveController.kiss new file mode 100644 index 00000000..2fdac40c --- /dev/null +++ b/projects/nat-archive-tool/src/nat/ArchiveController.kiss @@ -0,0 +1,12 @@ +(defmethod selectEntry [:Entry e] + (set selectedEntries [e])) + +(defmethod selectEntries [:Array e] + (set selectedEntries e)) + +(defnew [&prop :Archive archive + &prop :ArchiveUI ui] + [&mut :Array selectedEntries [] + :Map commands (new Map)] + + ) \ No newline at end of file diff --git a/projects/nat-archive-tool/src/nat/ArchiveUI.hx b/projects/nat-archive-tool/src/nat/ArchiveUI.hx new file mode 100644 index 00000000..1515584c --- /dev/null +++ b/projects/nat-archive-tool/src/nat/ArchiveUI.hx @@ -0,0 +1,30 @@ +package nat; + +import nat.ArchiveController; + +interface ArchiveUI { + /** + * Prompt the user to enter text + */ + function enterText(?minLength:Int, ?maxLength:Int):String; + + /** + * Prompt the user to enter a number + */ + function enterNumber(?min:Float, ?max:Float, ?inStepsOf:Float):Float; + + /** + * Prompt the user to choose a single Entry + */ + function chooseEntry(archive:Archive):Entry; + + /** + * Prompt the user to choose multiple Entries + */ + function chooseEntries(archive:Archive, ?min:Int, ?max:Int):Array; + + /** + * Update the interface to reflect changes made to Entries through commands + */ + function handleChanges(changeSet:ChangeSet):Void; +} \ No newline at end of file diff --git a/projects/nat-archive-tool/src/nat/CLI.hx b/projects/nat-archive-tool/src/nat/CLI.hx new file mode 100644 index 00000000..4319a767 --- /dev/null +++ b/projects/nat-archive-tool/src/nat/CLI.hx @@ -0,0 +1,9 @@ +package nat; + +import kiss.Prelude; +import kiss.List; +import kiss.Operand; +import sys.FileSystem; + +@:build(kiss.Kiss.build()) +class CLI implements ArchiveUI {} diff --git a/projects/nat-archive-tool/src/nat/CLI.kiss b/projects/nat-archive-tool/src/nat/CLI.kiss new file mode 100644 index 00000000..0977e965 --- /dev/null +++ b/projects/nat-archive-tool/src/nat/CLI.kiss @@ -0,0 +1,21 @@ +(defun :Void main [] + (let [[archiveDir] (Sys.args) + controller + (new ArchiveController + (new Archive archiveDir) + (new CLI))] + )) + +(defmethod enterText [&opt minLength maxLength] + "") + +(defmethod enterNumber [&opt min max inStepsOf] + 0) + +(defmethod chooseEntry [archive] + null) + +(defmethod chooseEntries [archive &opt min max] + []) + +(defmethod :Void handleChanges [changeSet] 0) \ No newline at end of file