run multiple NATCommands
This commit is contained in:
@@ -128,16 +128,20 @@
|
|||||||
(lambda :Void []
|
(lambda :Void []
|
||||||
(_collectAndValidateArg arg stream ->:Void [:Dynamic argValue] {(collectedArgs.push argValue) (lastCollector)})))
|
(_collectAndValidateArg arg stream ->:Void [:Dynamic argValue] {(collectedArgs.push argValue) (lastCollector)})))
|
||||||
|
|
||||||
(method :Void tryRunCommand [:String command]
|
(method :Void tryRunCommand [:String command &opt :Void->Void doAfter]
|
||||||
(let [parts (command.split " ")
|
(let [parts (command.split " ")
|
||||||
commandName (parts.shift)
|
commandName (parts.shift)
|
||||||
stream (Stream.fromString (parts.join " "))
|
stream (Stream.fromString (parts.join " "))
|
||||||
lowerCommandName (commandName.toLowerCase)]
|
lowerCommandName (commandName.toLowerCase)]
|
||||||
(if (commands.exists lowerCommandName)
|
(if (commands.exists lowerCommandName)
|
||||||
(_runCommand (dictGet commands lowerCommandName) stream)
|
(_runCommand (dictGet commands lowerCommandName) stream doAfter)
|
||||||
(ui.reportError "$commandName is not a valid command"))))
|
(ui.reportError "$commandName is not a valid command"))))
|
||||||
|
|
||||||
(method :Void _runCommand [:Command command :Stream stream]
|
(method :Void tryRunCommands [:Array<String> commands]
|
||||||
|
(when commands
|
||||||
|
(tryRunCommand (commands.shift) ->:Void (tryRunCommands commands))))
|
||||||
|
|
||||||
|
(method :Void _runCommand [:Command command :Stream stream &opt :Void->Void doAfter]
|
||||||
(let [collectedArgs
|
(let [collectedArgs
|
||||||
[]
|
[]
|
||||||
&mut lastCollector
|
&mut lastCollector
|
||||||
@@ -149,7 +153,8 @@
|
|||||||
(when lastChangeSet
|
(when lastChangeSet
|
||||||
(doFor e lastChangeSet
|
(doFor e lastChangeSet
|
||||||
(assert (and e (isEntry e)) "Lib function forgot to return the Entry that was modified"))
|
(assert (and e (isEntry e)) "Lib function forgot to return the Entry that was modified"))
|
||||||
(ui.handleChanges archive lastChangeSet))))]
|
(ui.handleChanges archive lastChangeSet)
|
||||||
|
(when doAfter (doAfter)))))]
|
||||||
// To facilitate asynchronous arg input via UI, we need to construct an insanely complicated nested callback to give the UI
|
// To facilitate asynchronous arg input via UI, we need to construct an insanely complicated nested callback to give the UI
|
||||||
(doFor arg (reverse command.args)
|
(doFor arg (reverse command.args)
|
||||||
(set lastCollector (_composeArgCollector collectedArgs arg stream lastCollector)))
|
(set lastCollector (_composeArgCollector collectedArgs arg stream lastCollector)))
|
||||||
@@ -321,6 +326,12 @@
|
|||||||
(AddKeyShortcut e description)
|
(AddKeyShortcut e description)
|
||||||
(AddNATCommand [e] command)})])
|
(AddNATCommand [e] command)})])
|
||||||
|
|
||||||
|
(defCommand CreateMultiCommandShortcut [description (Text null) commands (VarText null)]
|
||||||
|
[(archive.createEntry ->e {
|
||||||
|
(addComponent archive e Name description)
|
||||||
|
(AddKeyShortcut e description)
|
||||||
|
(AddNATCommands [e] commands)})])
|
||||||
|
|
||||||
(defCommand AddFiles [entries (SelectedEntries 1 null)
|
(defCommand AddFiles [entries (SelectedEntries 1 null)
|
||||||
// TODO add File and Files as an argument type for commands, ArchiveUI
|
// TODO add File and Files as an argument type for commands, ArchiveUI
|
||||||
// TODO make tkinter file browser externs and use tkinter as the file picking mechanism for CLI
|
// TODO make tkinter file browser externs and use tkinter as the file picking mechanism for CLI
|
||||||
|
|||||||
@@ -32,6 +32,5 @@
|
|||||||
((hasComponent e NATCommand)
|
((hasComponent e NATCommand)
|
||||||
(controller.tryRunCommand (readComponent e NATCommand)) 0)
|
(controller.tryRunCommand (readComponent e NATCommand)) 0)
|
||||||
((hasComponent e NATCommands)
|
((hasComponent e NATCommands)
|
||||||
// TODO chain them together asynchronously (they may be partial)
|
(controller.tryRunCommands (readComponent e NATCommands)) 0)
|
||||||
0)
|
|
||||||
(true (ui.displayMessage "tried to invoke ${e.id} but it has no available actions"))) 0)
|
(true (ui.displayMessage "tried to invoke ${e.id} but it has no available actions"))) 0)
|
||||||
@@ -134,6 +134,8 @@
|
|||||||
(case [text action]
|
(case [text action]
|
||||||
([text FlxInputText.ENTER_ACTION]
|
([text FlxInputText.ENTER_ACTION]
|
||||||
(clearUI)
|
(clearUI)
|
||||||
|
(set textInput.callback null)
|
||||||
|
(set textInput null)
|
||||||
(resolve text))
|
(resolve text))
|
||||||
//([_ FlxInputText.])
|
//([_ FlxInputText.])
|
||||||
(otherwise {}))))
|
(otherwise {}))))
|
||||||
|
|||||||
Reference in New Issue
Block a user