1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00
guile/examples/scripts/hello
Martin Grabmüller 673509f84f * scripts/README, scripts/hello.scm, safe/untrusted.scm,
safe/evil.scm, safe/README, modules/README, modules/main,
	modules/module-0.scm, modules/module-1.scm, modules/module-2.scm:
	Minor cleanup.

	* README: Added intro stuff, restructured a bit.

	* box-dynamic/README, box-module/README, box/README: Cleanup and
	restructuring.

	* box-dynamic-module/box-mixed.scm: New file, demonstrating usage
	of extension library functionality, but without exporting
	procedures from the library.

	Thanks to Thomas Wawrzinek for the idea and example code!

	* box-dynamic-module/box-module.scm: Add comments, export
	make-box, box-ref, box-set!.

	* box-dynamic-module/README: Integrate new module (box-mixed),
	restructure and cleanup a bit.
2001-06-14 20:36:06 +00:00

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
;;; decription 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 and exit.
;;
(define (display-version)
(display "hello 0.0.1\n"))
;; Display the usage help message and exit.
;;
(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: