]> git.jsancho.org Git - guile-click.git/blob - tests/test-args.scm
WIP: Nested commands
[guile-click.git] / tests / test-args.scm
1 ;;; Click --- Command Line Interface Creation Kit for GNU Guile
2 ;;; Copyright © 2021 Javier Sancho <jsf@jsancho.org>
3 ;;;
4 ;;; This file is part of Click.
5 ;;;
6 ;;; Click is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or
9 ;;; (at your option) any later version.
10 ;;;
11 ;;; Click is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 ;;; General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with Click.  If not, see <http://www.gnu.org/licenses/>.
18
19
20 (define-module (tests test-args)
21   #:use-module (srfi srfi-64)
22   #:use-module (click args))
23
24
25 (test-begin "test-args")
26
27 (define option-spec
28   '((count (single-char #\c) (default 1))
29     (name  (prompt "Your name"))
30     (help  (flag #t))))
31
32 (test-error #t (parse-args '("program" "--count") option-spec))
33
34 (test-error #t (parse-args '("program" "-x") option-spec))
35
36 (test-equal (parse-args '("program" "-c" "2" "--name" "joe") option-spec)
37             '((()) (name . "joe") (count . "2")))
38
39 (test-equal (parse-args '("program" "-c" "2" "command" "-x") option-spec)
40             '((() "command" "-x") (count . "2")))
41
42 (test-equal (get-values option-spec '((()) (name . "joe") (count . "2")))
43             '((count . 2) (name . "joe") (help . #f)))
44               
45 (test-end "test-args")