summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2023-07-08 00:06:16 -0500
committerCase Duckworth2023-07-08 00:06:16 -0500
commit82b0f24ab39665e962abd002dbb7ba6631181ec1 (patch)
treede23a94934d0c824a0ef9041d967ab2bd62a3120
parentInitial commit (diff)
downloadboudin-82b0f24ab39665e962abd002dbb7ba6631181ec1.tar.gz
boudin-82b0f24ab39665e962abd002dbb7ba6631181ec1.zip
Refactor usage
-rwxr-xr-xboudin.scm27
1 files changed, 17 insertions, 10 deletions
diff --git a/boudin.scm b/boudin.scm index 737cbf1..082542b 100755 --- a/boudin.scm +++ b/boudin.scm
@@ -364,19 +364,26 @@ boudin --- a little static site generator
364 364
365;;; Options & Operands (SRFI 37) 365;;; Options & Operands (SRFI 37)
366 366
367(define (die error-code message . args)
368 (with-output-to-port (current-error-port)
369 (apply print message args)
370 (exit error-code)))
371
372(define usage #<<END
373Usage: boudin [OPTIONS]
374Options:
375-h, --help show this help and exit
376-C dir, --directory dir build site in DIR instead of current directory
377END
378)
379
367(define opt/help 380(define opt/help
368 (option '(#\h "help") ; Names 381 (option '(#\h "help") ; Names
369 #f ; Required arg? 382 #f ; Required arg?
370 #f ; Optional arg? 383 #f ; Optional arg?
371 (lambda _ ; Option proc (opt name arg seeds ...) 384 (lambda _ ; Option proc (opt name arg seeds ...)
372 (with-output-to-port (current-error-port) 385 (with-output-to-port (current-error-port)
373 (lambda () 386 (lambda () (print usage)))
374 (print "Usage: boudin [OPTIONS]\n"
375 "Options:\n"
376 "-h, --help show this help and exit\n"
377 "-C dir, --directory dir\n"
378 " build site in DIR instead of current directory"
379 )))
380 (exit)))) 387 (exit))))
381 388
382(define opt/directory 389(define opt/directory
@@ -394,10 +401,10 @@ boudin --- a little static site generator
394 opt/directory) 401 opt/directory)
395 ;; Unrecognized option proc (option name arg seeds ...) 402 ;; Unrecognized option proc (option name arg seeds ...)
396 (lambda (_ name _ _) 403 (lambda (_ name _ _)
397 (error "Unrecognized option" name)) 404 (die 1 "Unrecognized option: -" name "\n" usage))
398 ;; Operand proc (operand seeds ...) 405 ;; Operand proc (operand seeds ...)
399 (lambda (name _) 406 (lambda (name _)
400 (error "Bad operand" name)) 407 (die 1 "Unrecognized operand: " name "\n" usage))
401 ;; Seeds 408 ;; Seeds
402 '())) 409 '()))
403 410
@@ -405,7 +412,7 @@ boudin --- a little static site generator
405 412
406(define (main args) 413(define (main args)
407 (process-args args) 414 (process-args args)
408 415 ;; TODO ...
409 #f) 416 #f)
410 417
411(cond-expand 418(cond-expand