Permalink
Browse files

New launcher by Mario Goulart. Capital stuff.

  • Loading branch information...
1 parent e471964 commit ff0c9df3b089aace18141ca47ebc1b1fa702bb9b Sean Grove committed Apr 15, 2010
Showing with 37 additions and 8 deletions.
  1. +8 −2 README.md
  2. +29 −6 launcher.scm
View
@@ -19,11 +19,17 @@ To install, first install chicken scheme, and then:
sudo chicken-install glut
git clone git://github.com/sgrove/tehila.git
-That's it! Tehila is setup with all its dependencies. Now edit launcher.scheme to pick an example to run, then
+That's it! Tehila is setup with all its dependencies.
+
+For general usage, pass your logic file to Tehila by:
+
+ csi launcher.scm <some-logic-file.scm>
+
+If you omit any file, then the launcher will give you a menu to launch any file in the examples/ directory
csi launcher.scm
-And you should see your chosen example appear. For all the examples available, check out the examples directory, or "csi launcher.scm"
+Choose one and you should the example appear.
Tutorials
---------
View
@@ -1,7 +1,30 @@
-;; (define *logic-file* "examples/nehe_tutorials_2.scm")
-;; (define *logic-file* "examples/nehe_tutorials_3.scm")
-;; (define *logic-file* "examples/nehe_tutorials_4.scm")
-(define *logic-file* "examples/nehe_tutorials_5.scm")
-;; (define *logic-file* "examples/tehila_basic_camera.scm")
+(use posix srfi-1)
-(load "lib/core.scm")
+(define (usage #!optional exit-code)
+ (print (pathname-strip-directory (program-name)) " [ --help ] [ <example-file> ]")
+ (when exit-code (exit exit-code)))
+
+(define (prompt-example)
+ (let* ((example-files (sort (glob (make-pathname "examples" "*.scm")) string<))
+ (example-indices (iota (length example-files))))
+ (let loop ()
+ (print "Select one of the examples below:")
+ (for-each (lambda (i ex)
+ (print i ". " (pathname-file ex)))
+ example-indices
+ example-files)
+ (display "Example number (press ENTER to abort): ")
+ (let ((selected-index (string->number (read-line))))
+ (unless selected-index (exit 0))
+ (if (memq selected-index example-indices)
+ (list-ref example-files selected-index)
+ (loop))))))
+
+(let ((args (command-line-arguments)))
+ (print args)
+ (when (member "--help" args) (usage 0))
+ (set! *logic-file*
+ (if (null? (cdr args))
+ (prompt-example)
+ (cadr args)))
+ (load "lib/core.scm"))

0 comments on commit ff0c9df

Please sign in to comment.