Revised method for re-reading the executable as data.
[rrq/newlisp/packnl.git] / main-args.lsp
1 ;; Utility function to process the main arguments into options and other
2 ;; using a given template
3
4 ; The input arguments (less options 
5 (constant 'ARGS (1 (main-args)))
6
7 ; The command line options replaced with actuals, in order.
8 (constant
9  'OPTIONS
10  (map (fn (O)
11         (if (collect 
12              (if (match (flat (list '* O '*)) ARGS)
13                  (let ((A ($it 0)) (B ($it -1))
14                        (C (slice $it 1 (- (length $it) 2))))
15                    (constant 'ARGS (append A B)) C)))
16             (cons O $it)))
17       OPTIONS))
18