]> git.jsancho.org Git - guile-click.git/blob - examples/hello.scm
Prompt for values
[guile-click.git] / examples / hello.scm
1 #!/usr/bin/guile-3.0 --no-auto-compile
2 -*- scheme -*-
3 !#
4 ;;; Click --- Command Line Interface Creation Kit for GNU Guile
5 ;;; Copyright © 2021 Javier Sancho <jsf@jsancho.org>
6 ;;;
7 ;;; This file is part of Click.
8 ;;;
9 ;;; Click is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or
12 ;;; (at your option) any later version.
13 ;;;
14 ;;; Click is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 ;;; General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with Click.  If not, see <http://www.gnu.org/licenses/>.
21
22
23 (use-modules (click))
24
25
26 (define hello
27   (command
28    '((count (single-char #\c) (default 1) (help "Number of greetings."))
29      (name (prompt "Your name") (help "The person to greet.")))
30    (lambda (count name)
31      "Simple program that greets NAME for a total of COUNT times."
32      (let loop ((times count))
33        (cond ((> times 0)
34               (format #t "Hello ~a!~%" name)
35               (loop (- times 1))))))))
36
37 (hello (command-line))