Skip to content

Commit

Permalink
Add a new module to let the user get help for commands
Browse files Browse the repository at this point in the history
  • Loading branch information
mwitmer committed Feb 4, 2014
1 parent 85bbdd1 commit c1ea323
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions module/guile-wm/module/help.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(define-module (guile-wm module help)
#:use-module (guile-wm command)
#:use-module (guile-wm shared)
#:use-module (language command spec))

(use-wm-modules message menu)

(define-command (help)
"List all the commands and show documentation for the one selected
by the user"
(menu "Select a command:"
(map (lambda (c) (cons (symbol->string c) (command-documentation c)))
(hash-map->list (lambda (k v) k) commands))
(lambda (doc)
(if doc (message doc) (message "Not documented")))))

(define-command (document (cmd #:symbol))
"Display docstring for command CMD"
(or
(and=> (command-documentation cmd) message)
(message (format #f "No command with name ~a" cmd))))

0 comments on commit c1ea323

Please sign in to comment.