如何在鸡肉中使用getopt-long

时间:2013-08-05 02:15:48

标签: getopt-long chicken-scheme

如何在鸡肉中使用getopt-long

我有以下代码:

(require 'getopt-long)

(define grammar 
  `((help (required #f)
          (value #f)
          (single-char #\h))
(limit (required #t)
       (value #f) ;; optional value
       (single-char #\l)
       (value (required INTEGER)
              (predicate ,integer?)))
    ))

(getopt-long '(program-arguments) grammar)

但是当我尝试使用csi运行代码时,出现以下错误:

Error: unbound variable: getopt-long

    Call history:

    <eval>    (##sys#list (##sys#list (##core#quote help) (##sys#list (##core#quote required) (##core#quote #f)) (......
    <eval>    (##sys#list (##core#quote help) (##sys#list (##core#quote required) (##core#quote #f)) (##sys#list (......
    <eval>    (##sys#list (##core#quote required) (##core#quote #f))
    <eval>    (##sys#list (##core#quote value) (##core#quote #f))
    <eval>    (##sys#list (##core#quote single-char) (##core#quote #\h))
    <eval>    (##sys#list (##core#quote limit) (##sys#list (##core#quote required) (##core#quote #t)) (##sys#list ...
    <eval>    (##sys#list (##core#quote required) (##core#quote #t))
    <eval>    (##sys#list (##core#quote value) (##core#quote #f))
    <eval>    (##sys#list (##core#quote single-char) (##core#quote #\l))
    <eval>    (##sys#list (##core#quote value) (##sys#list (##core#quote required) (##core#quote INTEGER)) (##sys#......
    <eval>    (##sys#list (##core#quote required) (##core#quote INTEGER))
    <eval>    (##sys#list (##core#quote predicate) integer?)
    <syntax>      (getopt-long (quote (program-arguments)) grammar)
    <syntax>      (quote (program-arguments))
    <syntax>      (##core#quote (program-arguments))
    <eval>    (getopt-long (quote (program-arguments)) grammar) <--

任何想法?

1 个答案:

答案 0 :(得分:1)

我找出了getopt-long时遇到的问题。您必须使用getopt-long加载use,如下所示:

(use getopt-long)

(define grammar 
  `((help (required #f)
          (value #f)
          (single-char #\h))
(limit (required #f)
       (value #f) ;; optional value
       (single-char #\l)
       (value (required INTEGER)
              (predicate ,integer?)))))
(getopt-long (argv) grammar)