A simple and flexible command-line option parsing facility.
See the SRFI-37 document.
This extension supports static linking.
#!/usr/local/bin/csi -script ;;;; secho - display command-line arguments (define nl 1) (define help (option '(#\h "help") #f #f (lambda _ (print "Usage: secho [OPTION] ARG ... -h --help show this text -n --newline N add N newline characters (default: 1)") (exit) ) ) ) (define newlines (option '(#\n "newline") #t #f (lambda (o n x vals) (set! nl (string->number x)) vals) ) ) (for-each (lambda (x) (print* x #\space)) (reverse (args-fold (command-line-arguments) (list help newlines) (lambda (o n x vals) (error "unrecognized option" n) ) cons '() ) ) ) (display (make-string nl #\newline))
- 1.2 - Changed license to the one acually used by the reference implementation [Thanks to Ivan Shmakov for pointing this out]
- 1.1 - support for static linking
- 1.0 - Initial release
Copyright (C) Anthony Carrico (2002). All Rights Reserved.
This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Scheme Request For Implementation process or editors, except as needed for the purpose of developing SRFIs in which case the procedures for copyrights defined in the SRFI process must be followed, or as required to translate it into languages other than English. The limited permissions granted above are perpetual and will not be revoked by the authors or their successors or assigns. This document and the information contained herein is provided on an ``AS IS'' basis and THE AUTHOR AND THE SRFI EDITORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.