add command parameters (as long as there are none)

This commit is contained in:
Daniel Barlow 2022-12-19 21:01:10 +00:00
parent 38786d3790
commit 102afaa90e
2 changed files with 8 additions and 3 deletions

View File

@ -8,9 +8,14 @@
(define-command "quit-browser" #(Gtk.main_quit) {}) (define-command "quit-browser" #(Gtk.main_quit) {})
(fn invoke [s] (fn prompt-missing-args [params explicit-args]
explicit-args)
(fn invoke [s args]
(match (. commands s) (match (. commands s)
{:function f :params p} (f) {:function f :params p}
(let [prompted-args (prompt-missing-args p args)]
(f prompted-args))
nil (print "undefined command " s))) nil (print "undefined command " s)))

View File

@ -17,7 +17,7 @@
commander (Gtk.Entry { commander (Gtk.Entry {
:on_activate :on_activate
(fn [event] (fn [event]
(command.invoke event.text)) (command.invoke event.text {}))
}) })
progress-bar (Gtk.ProgressBar { progress-bar (Gtk.ProgressBar {
:orientation Gtk.Orientation.HORIZONTAL :orientation Gtk.Orientation.HORIZONTAL