Debian Codegraph @

examples/cmdline/ls.lsp

raw
1 #|
2 To create a program called ls.exe type the following lines
3 from a lisp prompt:
4
5 (compile-file "ls.lsp" :output-file "ls.o" :system-p t)
6 (c::build-program "ls" :lisp-files '("ls.o"))
7
8 NOTE: The content of this file must match the example in the
9 documentation.
10 |#
11
12 (setq ext:*help-message* "
13 ls [--help | -?] filename*
14
15 Lists the file that match the given patterns.
16 ")
17
18 (defun print-directory (pathnames)
19 (format t "~{~A~%~}"
20 (mapcar #'(lambda (x) (enough-namestring x (si::getcwd)))
21 (mapcan #'directory (or pathnames '("*.*" "*/"))))))
22
23 (defconstant +ls-rules+
24 '(("--help" 0 (progn (princ ext:*help-message* *standard-output*) (ext:quit 0)))
25 ("-?" 0 (progn (princ ext:*help-message* *standard-output*) (ext:quit 0)))
26 ("*DEFAULT*" 1 (print-directory 1) :stop)))
27
28 (let ((ext:*lisp-init-file-list* NIL)) ; No initialization files
29 (handler-case (ext:process-command-args :rules +ls-rules+)
30 (error (c)
31 (princ ext:*help-message* *error-output*)
32 (ext:quit 1))))
33 (ext:quit 0)