diff --git a/beautiful-racket-demo/basic-demo-3/args.rkt b/beautiful-racket-demo/basic-demo-3/args.rkt new file mode 100644 index 0000000..2f921ea --- /dev/null +++ b/beautiful-racket-demo/basic-demo-3/args.rkt @@ -0,0 +1,2 @@ +#lang br +(current-command-line-arguments) \ No newline at end of file diff --git a/beautiful-racket-demo/basic-demo-3/expander.rkt b/beautiful-racket-demo/basic-demo-3/expander.rkt index 59f02f0..5f2ec23 100644 --- a/beautiful-racket-demo/basic-demo-3/expander.rkt +++ b/beautiful-racket-demo/basic-demo-3/expander.rkt @@ -12,9 +12,7 @@ (find-property 'b-import-name #'(LINE ...))] [(EXPORT-NAME ...) (find-property 'b-export-name #'(LINE ...))] - [((SHELL-ID SHELL-VAL) ...) - (for/list ([(val idx) (in-indexed (current-command-line-arguments))]) - (list (suffix-id #'arg idx #:context caller-stx) val))]) + [((SHELL-ID SHELL-VAL) ...) (handle-shell caller-stx)]) #'(#%module-begin (module configure-runtime br (require basic-demo-3/setup) @@ -37,5 +35,11 @@ (for/list ([stx (in-list (stx-flatten line-stxs))] #:when (syntax-property stx which)) stx) - #:key syntax->datum))) + #:key syntax->datum)) + + (define (handle-shell ctxt) + (for/list + ([(val idx) + (in-indexed (current-command-line-arguments))]) + (list (suffix-id #'arg idx #:context ctxt) val)))) diff --git a/beautiful-racket-demo/basic-demo-3/sample-shell.rkt b/beautiful-racket-demo/basic-demo-3/sample-shell.rkt index 7742dd5..24b07d2 100644 --- a/beautiful-racket-demo/basic-demo-3/sample-shell.rkt +++ b/beautiful-racket-demo/basic-demo-3/sample-shell.rkt @@ -1,4 +1,2 @@ #lang basic-demo-3 -10 print "got shell arg" : print arg0 : print arg1 -20 a = 5 -30 def f(x) = x ^ x \ No newline at end of file +10 print "got shell args: " ; arg0 ; arg1 ; arg2 \ No newline at end of file