@@ -1860,18 +1860,33 @@ Arguments FNC and ARGS are used for advice `:around'."
18601860 (eask-msg (ansi-white (buffer-string )))
18611861 (eask-msg (concat " ''" (spaces-string max-column) " ''" ))))
18621862
1863- (defun eask-help (command )
1864- " Show COMMAND's help instruction."
1863+ (defun eask-help (command &optional print-or-exit-code )
1864+ " Show COMMAND's help instruction.
1865+
1866+ When the optional variable PRINT-OR-EXIT-CODE is a number, it will exit with
1867+ that code. Set to non-nil would just print the help message without sending
1868+ the exit code. The default value `nil' will be replaced by `1' ; therefore
1869+ would send exit code of `1' ."
18651870 (let* ((command (eask-2str command)) ; convert to string
1866- (help-file (concat eask-lisp-root " help/" command)))
1871+ (help-file (concat eask-lisp-root " help/" command))
1872+ ; ; The default exit code is `1' since `eask-help' prints the help
1873+ ; ; message on user error 99% of the time.
1874+ ; ;
1875+ ; ; TODO: Later replace exit code `1' with readable symbol after
1876+ ; ; the exit code has specified.
1877+ (print-or-exit-code (or print-or-exit-code 1 )))
18671878 (if (file-exists-p help-file)
18681879 (with-temp-buffer
18691880 (insert-file-contents help-file)
18701881 (unless (string-empty-p (buffer-string ))
18711882 (let ((buf-str (eask--msg-displayable-kwds (buffer-string ))))
18721883 (erase-buffer )
18731884 (insert buf-str))
1874- (eask--help-display)))
1885+ (eask--help-display))
1886+ ; ; Exit with code if needed
1887+ (cond ((numberp print-or-exit-code)
1888+ (eask--exit print-or-exit-code))
1889+ (t ))) ; Don't exit with anything else.
18751890 (eask-error " Help manual missing %s" help-file))))
18761891
18771892; ;
0 commit comments