(local { : Gtk  } (require :lgi))

(local commands {})

(fn define-command [name function params]
  (let [v {:name name :function function :params params}]
    (tset commands name v)))

(define-command "quit-browser" #(Gtk.main_quit) {})

(fn prompt-missing-args [params explicit-args]
  explicit-args)

(fn invoke [s args]
  (match (. commands s)
    {:function f :params p}
    (let [prompted-args (prompt-missing-args p args)]
      (f prompted-args))
    nil (print "undefined command " s)))


{ : invoke }
