blob: 6c47d4b0d9d44f53f5d7994e2320d366e87956dc (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
(use-package :chains)
(alexandria:define-constant +command-line-options+
'((:help #\h)
(:help "help")
(:use #\u :required)
(:use "use" :required)
(:use #\i :required)
(:use "include" :required))
:test #'equal
:documentation "")
(defun help ()
(format t "~&Usage: chains [OPTION]... FILE...
-i, --include
-u, --use
-h, --help
"))
(defun parse-arguments (command-line-arguments)
(multiple-value-bind (options others unknowns)
(just-getopt-parser:getopt command-line-arguments +command-line-options+)
(cond ((assoc :help options)
(help)
(sb-posix:exit 0))
(unknowns
(help)
(sb-posix:exit 1))
(t
(loop :for (option . value) :in options :do
(case option
))))
others))
(defun chains ()
(let ((files (parse-arguments (uiop:command-line-arguments))))
(dolist (file files)
(with-open-file (stream file :direction :input)
(mapc (alexandria:compose #'princ #'chains::content)
(alexandria:flatten (chains:eval-tree chains:*default-environment*
(chains:build-tree
(chains:read-tokens stream)))))))))
|