Function: eshell-show-usage

eshell-show-usage is a byte-compiled function defined in esh-opt.el.gz.

Signature

(eshell-show-usage NAME OPTIONS)

Documentation

Display the usage message for NAME, using OPTIONS.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-opt.el.gz
(defun eshell-show-usage (name options)
  "Display the usage message for NAME, using OPTIONS."
  (require 'esh-ext)
  (declare-function eshell-search-path "esh-ext" (name))
  (let ((usage (format "usage: %s %s\n\n" name
		       (cadr (memq ':usage options))))
	(extcmd (memq ':external options))
	(post-usage (memq ':post-usage options))
	had-option)
    (while options
      (when (listp (car options))
	(let ((opt (car options)))
	  (setq had-option t)
	  (cond ((and (nth 0 opt)
		      (nth 1 opt))
		 (setq usage
		       (concat usage
			       (format "    %-20s %s\n"
				       (format "-%c, --%s" (nth 0 opt)
					       (nth 1 opt))
				       (nth 4 opt)))))
		((nth 0 opt)
		 (setq usage
		       (concat usage
			       (format "    %-20s %s\n"
				       (format "-%c" (nth 0 opt))
				       (nth 4 opt)))))
		((nth 1 opt)
		 (setq usage
		       (concat usage
			       (format "    %-20s %s\n"
				       (format "    --%s" (nth 1 opt))
				       (nth 4 opt)))))
		(t (setq had-option nil)))))
      (setq options (cdr options)))
    (if post-usage
	(setq usage (concat usage (and had-option "\n")
			    (cadr post-usage))))
    (when extcmd
      (setq extcmd (eshell-search-path (cadr extcmd)))
      (if extcmd
	  (setq usage
		(concat usage
			(format-message "
This command is implemented in Lisp.  If an unrecognized option is
passed to this command, the external version `%s'
will be called instead." extcmd)))))
    (throw 'eshell-usage usage)))