From 0bb09006d51f6c8ed4a0f2af47ba0fc2c1f6defc Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 12 Jun 2024 13:43:40 +0300 Subject: [PATCH 1/2] add support for gerbil -r|--run --- src/gerbil/gxi-main.ss | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gerbil/gxi-main.ss b/src/gerbil/gxi-main.ss index 102b12d97..c5d1368f1 100644 --- a/src/gerbil/gxi-main.ss +++ b/src/gerbil/gxi-main.ss @@ -9,6 +9,7 @@ (displayln " -h|--help|help display this help message exit") (displayln " -v||--version|version display the system version and exit") (displayln " -L|--load module|file import a module (if begins with :) or load a file") + (displayln " -r|--run module import a module and run its main function with the remaining arguments") (displayln " -l|--lang module set the current interpretation language; must precede any evaluation") (displayln " -e|--eval evaluate an expression") (displayln) @@ -52,6 +53,13 @@ (lp rest)) (else (error "missing argument for file to load")))) + ((member hd '("-r" "--run")) + (match rest + ([x . rest] + (eval `(import ,x)) + (try-main! rest (lambda (args) (error "cannot run module" x args)))) + (else + (error "missing argument for module to run")))) ((member hd '("-l" "--lang")) (if can-set-lang? (match rest From 04211dc54ce802a799d1c3928a21cd9b11417494 Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 12 Jun 2024 13:47:17 +0300 Subject: [PATCH 2/2] improv --- src/gerbil/gxi-main.ss | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gerbil/gxi-main.ss b/src/gerbil/gxi-main.ss index c5d1368f1..54fe275ad 100644 --- a/src/gerbil/gxi-main.ss +++ b/src/gerbil/gxi-main.ss @@ -56,8 +56,11 @@ ((member hd '("-r" "--run")) (match rest ([x . rest] - (eval `(import ,x)) - (try-main! rest (lambda (args) (error "cannot run module" x args)))) + (let (mod (if (string-prefix? ":" x) + (string->symbol x) + x)) + (eval `(import ,mod)) + (try-main! rest (lambda (args) (error "cannot run module" x args))))) (else (error "missing argument for module to run")))) ((member hd '("-l" "--lang"))