WIP archive controllers
This commit is contained in:
@@ -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": ""
|
||||
|
@@ -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)
|
||||
|
26
src/nat/ArchiveController.hx
Normal file
26
src/nat/ArchiveController.hx
Normal file
@@ -0,0 +1,26 @@
|
||||
package nat;
|
||||
|
||||
import kiss.Prelude;
|
||||
import kiss.List;
|
||||
import kiss.Operand;
|
||||
|
||||
import haxe.Constraints;
|
||||
|
||||
enum CommandArgument {
|
||||
SelectedEntry;
|
||||
SelectedEntries(min:Null<Int>, max:Null<Int>);
|
||||
Text(minLength:Null<Int>, maxLength:Null<Int>);
|
||||
Number(min:Null<Float>, max:Null<Float>, inStepsOf:Null<Float>);
|
||||
Entry;
|
||||
Entries(min:Null<Int>, max:Null<Int>);
|
||||
}
|
||||
|
||||
typedef Command = {
|
||||
args:Array<CommandArgument>,
|
||||
handler:Function
|
||||
};
|
||||
|
||||
typedef ChangeSet = Array<Entry>;
|
||||
|
||||
@:build(kiss.Kiss.build())
|
||||
class ArchiveController {}
|
12
src/nat/ArchiveController.kiss
Normal file
12
src/nat/ArchiveController.kiss
Normal file
@@ -0,0 +1,12 @@
|
||||
(defmethod selectEntry [:Entry e]
|
||||
(set selectedEntries [e]))
|
||||
|
||||
(defmethod selectEntries [:Array<Entry> e]
|
||||
(set selectedEntries e))
|
||||
|
||||
(defnew [&prop :Archive archive
|
||||
&prop :ArchiveUI ui]
|
||||
[&mut :Array<Entry> selectedEntries []
|
||||
:Map<String,Command> commands (new Map)]
|
||||
|
||||
)
|
30
src/nat/ArchiveUI.hx
Normal file
30
src/nat/ArchiveUI.hx
Normal file
@@ -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<Entry>;
|
||||
|
||||
/**
|
||||
* Update the interface to reflect changes made to Entries through commands
|
||||
*/
|
||||
function handleChanges(changeSet:ChangeSet):Void;
|
||||
}
|
9
src/nat/CLI.hx
Normal file
9
src/nat/CLI.hx
Normal file
@@ -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 {}
|
21
src/nat/CLI.kiss
Normal file
21
src/nat/CLI.kiss
Normal file
@@ -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)
|
Reference in New Issue
Block a user