-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new module to let the user get help for commands
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)))) | ||
|