@@ -1860,18 +1860,33 @@ Arguments FNC and ARGS are used for advice `:around'."
1860
1860
(eask-msg (ansi-white (buffer-string )))
1861
1861
(eask-msg (concat " ''" (spaces-string max-column) " ''" ))))
1862
1862
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' ."
1865
1870
(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 )))
1867
1878
(if (file-exists-p help-file)
1868
1879
(with-temp-buffer
1869
1880
(insert-file-contents help-file)
1870
1881
(unless (string-empty-p (buffer-string ))
1871
1882
(let ((buf-str (eask--msg-displayable-kwds (buffer-string ))))
1872
1883
(erase-buffer )
1873
1884
(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.
1875
1890
(eask-error " Help manual missing %s" help-file))))
1876
1891
1877
1892
; ;
0 commit comments