chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] getopt, getopt_long?


From: Ivan Raikov
Subject: Re: [Chicken-users] getopt, getopt_long?
Date: Wed, 09 Jul 2008 08:57:08 +0900
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

The args egg provides getopt-like functionality:

(require-extension args)

(define opt_v #f)
                 
(define opts
  `(
    ,(args:make-option (v)       #:none               "set verbose mode"
                       (set! opt_v #t))
    ,(args:make-option (h help)  #:none               "Print help"
                       (usage))))


;; Use args:usage to generate a formatted list of options (from OPTS),
;; suitable for embedding into help text.
(define (usage)
  (print "Usage: " (car (argv)) " [options...] commands ")
  (newline)
  (print "The following options are recognized: ")
  (newline)
  (print (parameterize ((args:indent 5)) (args:usage opts)))
  (exit 1))


;; Process arguments and collate options and arguments into OPTIONS
;; alist, and operands (filenames) into OPERANDS.  You can handle
;; options as they are processed, or afterwards.

(set!-values (options operands)  
   (args:parse (command-line-arguments) opts))


William Xu <address@hidden> writes:

> Hi, 
>
> Does chicken have some egg for wrapping getopt, getopt_long? 

-- 
"Their eyes met, and his heart soared, like the price of gas before a
 long weekend." --Cornered, by Mike Baldwin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]