mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-29 19:30:36 +02:00
* NEWS: * README: * doc/r5rs/r5rs.texi: * doc/ref/api-data.texi: * doc/ref/api-debug.texi: * doc/ref/api-evaluation.texi: * doc/ref/api-io.texi: * doc/ref/api-macros.texi: * doc/ref/api-procedures.texi: * doc/ref/api-scheduling.texi: * doc/ref/api-undocumented.texi: * doc/ref/libguile-concepts.texi: * doc/ref/posix.texi: * doc/ref/srfi-modules.texi: * doc/ref/vm.texi: * doc/ref/web.texi: * examples/box-dynamic-module/box.c: * examples/box-dynamic/box.c: * examples/box-module/box.c: * examples/box/box.c: * examples/safe/safe: * examples/scripts/README: * examples/scripts/hello: * gc-benchmarks/larceny/twobit-input-long.sch: * gc-benchmarks/larceny/twobit-smaller.sch: * gc-benchmarks/larceny/twobit.sch: * libguile/expand.c: * libguile/load.c: * libguile/net_db.c: * libguile/scmsigs.c: * libguile/srfi-14.c: * libguile/threads.c: * meta/guile.m4: * module/ice-9/match.upstream.scm: * module/ice-9/ports.scm: * module/language/cps/graphs.scm: * module/scripts/doc-snarf.scm: * module/srfi/srfi-19.scm: * module/system/repl/command.scm: * test-suite/tests/srfi-18.test: Fix typos. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
57 lines
1.5 KiB
Scheme
Executable file
57 lines
1.5 KiB
Scheme
Executable file
#! /usr/local/bin/guile -s
|
|
!#
|
|
;;; Commentary:
|
|
|
|
;;; This is the famous Hello-World-program, written for Guile. It is a
|
|
;;; little bit enhanced in that it understands the command line options
|
|
;;; `--help' (-h) and `--version' (-v), which print a short usage
|
|
;;; description or version information, respectively.
|
|
|
|
;;; Author: Martin Grabmueller
|
|
;;; Date: 2001-05-29
|
|
|
|
;;; Code:
|
|
|
|
(use-modules (ice-9 getopt-long))
|
|
|
|
;; This is the grammar for the command line synopsis we expect.
|
|
;;
|
|
(define command-synopsis
|
|
'((version (single-char #\v) (value #f))
|
|
(help (single-char #\h) (value #f))))
|
|
|
|
;; Display version information.
|
|
;;
|
|
(define (display-version)
|
|
(display "hello 0.0.1\n"))
|
|
|
|
;; Display the usage help message.
|
|
;;
|
|
(define (display-help)
|
|
(display "Usage: hello [options...]\n")
|
|
(display " --help, -h Show this usage information\n")
|
|
(display " --version, -v Show version information\n"))
|
|
|
|
;; Interpret options, if --help or --version was given, print out the
|
|
;; requested information and exit. Otherwise, print the famous
|
|
;; message.
|
|
;;
|
|
(define (main options)
|
|
(let ((help-wanted (option-ref options 'help #f))
|
|
(version-wanted (option-ref options 'version #f)))
|
|
(if (or version-wanted help-wanted)
|
|
(begin
|
|
(if version-wanted
|
|
(display-version))
|
|
(if help-wanted
|
|
(display-help)))
|
|
(begin
|
|
(display "Hello, World!") (newline)))))
|
|
|
|
;; Call the main program with parsed command line options.
|
|
;;
|
|
(main (getopt-long (command-line) command-synopsis))
|
|
|
|
;; Local variables:
|
|
;; mode: scheme
|
|
;; End:
|