mirror of
https://github.com/false-schemers/skint.git
synced 2024-12-25 21:58:54 +01:00
-D, --define-feature cmd line option
This commit is contained in:
parent
de92c2ed52
commit
3c34a4cbae
2 changed files with 60 additions and 51 deletions
22
pre/t.scm
22
pre/t.scm
|
@ -2571,16 +2571,17 @@
|
|||
;--------------------------------------------------------------------------------------------------
|
||||
|
||||
(define *skint-options*
|
||||
'([verbose "-v" "--verbose" #f "Increase output verbosity"]
|
||||
[quiet "-q" "--quiet" #f "Suppress nonessential messages"]
|
||||
[append-libdir "-A" "--append-libdir" "DIR" "Append a library search directory"]
|
||||
[prepend-libdir "-I" "--prepend-libdir" "DIR" "Prepend a library search directory"]
|
||||
[eval "-e" "--eval" "SEXP" "Evaluate and print an expression"]
|
||||
[script "-s" "--script" "FILE" "Run file as a Scheme script"]
|
||||
[program "-p" "--program" "FILE" "Run file as a Scheme program"]
|
||||
'([verbose "-v" "--verbose" #f "Increase output verbosity"]
|
||||
[quiet "-q" "--quiet" #f "Suppress nonessential messages"]
|
||||
[append-libdir "-A" "--append-libdir" "DIR" "Append a library search directory"]
|
||||
[prepend-libdir "-I" "--prepend-libdir" "DIR" "Prepend a library search directory"]
|
||||
[define-feature "-D" "--define-feature" "NAME" "Add name to the list of features"]
|
||||
[eval "-e" "--eval" "SEXP" "Evaluate and print an expression"]
|
||||
[script "-s" "--script" "FILE" "Run file as a Scheme script"]
|
||||
[program "-p" "--program" "FILE" "Run file as a Scheme program"]
|
||||
;[benchmark #f "--benchmark" "FILE" "Run .sf benchmark file (internal)"]
|
||||
[version "-V" "--version" #f "Display version info"]
|
||||
[help "-h" "--help" #f "Display this help"]
|
||||
[version "-V" "--version" #f "Display version info"]
|
||||
[help "-h" "--help" #f "Display this help"]
|
||||
))
|
||||
|
||||
(define *skint-version* "0.3.9")
|
||||
|
@ -2591,6 +2592,8 @@
|
|||
(let ([obj (read-from-string str)])
|
||||
(for-each (lambda (val) (when print? (write val) (newline)))
|
||||
(call-with-values (lambda () (eval obj)) list))))
|
||||
(define (add-feature! f)
|
||||
(features (set-cons (string->symbol f) (features))))
|
||||
(define (print-version!)
|
||||
(format #t "(version ~s)~%(scheme.id skint)~%" *skint-version*))
|
||||
(define (print-help!)
|
||||
|
@ -2612,6 +2615,7 @@
|
|||
[(quiet) (set! *quiet* #t) (loop restargs #t)]
|
||||
[(append-libdir *) (append-library-path! optarg) (loop restargs #t)]
|
||||
[(prepend-libdir *) (prepend-library-path! optarg) (loop restargs #t)]
|
||||
[(define-feature *) (add-feature! optarg) (loop restargs #t)]
|
||||
[(eval *) (eval! optarg #t) (loop restargs #f)]
|
||||
[(script *) (set! *quiet* #t) (exit (run-script optarg restargs))]
|
||||
[(program *) (set! *quiet* #t) (exit (run-program optarg restargs))]
|
||||
|
|
89
t.c
89
t.c
|
@ -1625,53 +1625,58 @@ char *t_code[] = {
|
|||
",@(y16:repl-environment),.8^,@(y14:repl-from-port)[04}_3}t]3",
|
||||
|
||||
"C", 0,
|
||||
"'(l9:l5:y7:verbose;s2:-v;s9:--verbose;f;s25:Increase output verbosity;"
|
||||
";l5:y5:quiet;s2:-q;s7:--quiet;f;s30:Suppress nonessential messages;;l5"
|
||||
":y13:append-libdir;s2:-A;s15:--append-libdir;s3:DIR;s33:Append a libra"
|
||||
"ry search directory;;l5:y14:prepend-libdir;s2:-I;s16:--prepend-libdir;"
|
||||
"s3:DIR;s34:Prepend a library search directory;;l5:y4:eval;s2:-e;s6:--e"
|
||||
"val;s4:SEXP;s32:Evaluate and print an expression;;l5:y6:script;s2:-s;s"
|
||||
"8:--script;s4:FILE;s27:Run file as a Scheme script;;l5:y7:program;s2:-"
|
||||
"p;s9:--program;s4:FILE;s28:Run file as a Scheme program;;l5:y7:version"
|
||||
";s2:-V;s9:--version;f;s20:Display version info;;l5:y4:help;s2:-h;s6:--"
|
||||
"help;f;s17:Display this help;;)@!(y15:*skint-options*)",
|
||||
"'(l10:l5:y7:verbose;s2:-v;s9:--verbose;f;s25:Increase output verbosity"
|
||||
";;l5:y5:quiet;s2:-q;s7:--quiet;f;s30:Suppress nonessential messages;;l"
|
||||
"5:y13:append-libdir;s2:-A;s15:--append-libdir;s3:DIR;s33:Append a libr"
|
||||
"ary search directory;;l5:y14:prepend-libdir;s2:-I;s16:--prepend-libdir"
|
||||
";s3:DIR;s34:Prepend a library search directory;;l5:y14:define-feature;"
|
||||
"s2:-D;s16:--define-feature;s4:NAME;s32:Add name to the list of feature"
|
||||
"s;;l5:y4:eval;s2:-e;s6:--eval;s4:SEXP;s32:Evaluate and print an expres"
|
||||
"sion;;l5:y6:script;s2:-s;s8:--script;s4:FILE;s27:Run file as a Scheme "
|
||||
"script;;l5:y7:program;s2:-p;s9:--program;s4:FILE;s28:Run file as a Sch"
|
||||
"eme program;;l5:y7:version;s2:-V;s9:--version;f;s20:Display version in"
|
||||
"fo;;l5:y4:help;s2:-h;s6:--help;f;s17:Display this help;;)@!(y15:*skint"
|
||||
"-options*)",
|
||||
|
||||
"C", 0,
|
||||
"'(s5:0.3.9)@!(y15:*skint-version*)",
|
||||
|
||||
"P", "skint-main",
|
||||
"%0,,,,#0#1#2#3&0{%2${.2,@(y16:read-from-string)[01},${@(y4:list),.3,&1"
|
||||
"{%0:0,@(y4:eval)[01},@(y16:call-with-values)[02},.3,&1{%1:0?{Po,.1W5Po"
|
||||
"W6]1}]1},@(y10:%25for-each1)[32}.!0&0{%0@(y15:*skint-version*),'(s33:("
|
||||
"version ~s)~%25(scheme.id skint)~%25),t,@(y6:format)[03}.!1&0{%0${@(y1"
|
||||
"5:*skint-version*),'(s30:SKINT Scheme Interpreter v~a~%25),t,@(y6:form"
|
||||
"at)[03}${'(s42:usage: skint [OPTION]... [FILE] [ARG]...~%25),t,@(y6:fo"
|
||||
"rmat)[02}${'(s2:~%25),t,@(y6:format)[02}${'(s10:Options:~%25),t,@(y6:f"
|
||||
"ormat)[02}${Po,@(y15:*skint-options*),@(y26:print-command-line-options"
|
||||
")[02}${'(s2:~%25),t,@(y6:format)[02}${'(s80:'--' ends options processi"
|
||||
"ng. Standalone FILE argument is treated as a script.~%25),t,@(y6:forma"
|
||||
"t)[02}${'(s82:If no FILE is given, skint enters Read-Eval-Print loop ("
|
||||
"stdin>eval-print>stdout)~%25),t,@(y6:format)[02}'(s2:~%25),t,@(y6:form"
|
||||
"at)[02}.!2${@(y12:command-line)[00}.!3${t,.6^d,,#0.7,.1,.8,.8,&4{%2:0,"
|
||||
":1,:2,:3,.5,&5{%3.1?{.1,.1,l2}{.0,l1},${.2,'(l1:y7:verbose;),@(y11:sex"
|
||||
"p-match?)[02}?{t@!(y9:*verbose*)t,.4,:2^[42}${.2,'(l1:y5:quiet;),@(y11"
|
||||
":sexp-match?)[02}?{t@!(y7:*quiet*)t,.4,:2^[42}${.2,'(l2:y13:append-lib"
|
||||
"dir;y1:*;),@(y11:sexp-match?)[02}?{${.4,@(y20:append-library-path!)[01"
|
||||
"}t,.4,:2^[42}${.2,'(l2:y14:prepend-libdir;y1:*;),@(y11:sexp-match?)[02"
|
||||
"}?{${.4,@(y21:prepend-library-path!)[01}t,.4,:2^[42}${.2,'(l2:y4:eval;"
|
||||
"y1:*;),@(y11:sexp-match?)[02}?{${t,.5,:4^[02}f,.4,:2^[42}${.2,'(l2:y6:"
|
||||
"script;y1:*;),@(y11:sexp-match?)[02}?{t@!(y7:*quiet*)${.5,.5,@(y10:run"
|
||||
"-script)[02},@(y4:exit)[41}${.2,'(l2:y7:program;y1:*;),@(y11:sexp-matc"
|
||||
"h?)[02}?{t@!(y7:*quiet*)${.5,.5,@(y11:run-program)[02},@(y4:exit)[41}$"
|
||||
"{.2,'(l2:y9:benchmark;y1:*;),@(y11:sexp-match?)[02}?{${.5,.5,@(y10:run"
|
||||
"-script)[02},@(y4:exit)[41}${.2,'(l1:y7:version;),@(y11:sexp-match?)[0"
|
||||
"2}?{${:3^[00}f,n,:2^[42}${.2,'(l1:y4:help;),@(y11:sexp-match?)[02}?{${"
|
||||
":1^[00}f,n,:2^[42}${.2,'(l1:f;),@(y11:sexp-match?)[02}?{.3p?{t@!(y7:*q"
|
||||
"uiet*)${.5d,.6a,@(y10:run-script)[02},@(y4:exit)[41}:0~?{t,@(y4:exit)["
|
||||
"41}f]4}]4},@(y15:*skint-options*),.2,@(y28:get-next-command-line-optio"
|
||||
"n)[23}.!0.0^_1[02}PiP09?{PoP09}{f}?{${@(y15:*skint-version*),'(s30:SKI"
|
||||
"NT Scheme Interpreter v~a~%25),t,@(y6:format)[03}${'(s35:Copyright (c)"
|
||||
" 2024 False Schemers~%25),t,@(y6:format)[02}}t]4",
|
||||
"%0,,,,,#0#1#2#3#4&0{%2${.2,@(y16:read-from-string)[01},${@(y4:list),.3"
|
||||
",&1{%0:0,@(y4:eval)[01},@(y16:call-with-values)[02},.3,&1{%1:0?{Po,.1W"
|
||||
"5PoW6]1}]1},@(y10:%25for-each1)[32}.!0&0{%1${${@(y8:features)[00},.3X5"
|
||||
",@(y8:set-cons)[02},@(y8:features)[11}.!1&0{%0@(y15:*skint-version*),'"
|
||||
"(s33:(version ~s)~%25(scheme.id skint)~%25),t,@(y6:format)[03}.!2&0{%0"
|
||||
"${@(y15:*skint-version*),'(s30:SKINT Scheme Interpreter v~a~%25),t,@(y"
|
||||
"6:format)[03}${'(s42:usage: skint [OPTION]... [FILE] [ARG]...~%25),t,@"
|
||||
"(y6:format)[02}${'(s2:~%25),t,@(y6:format)[02}${'(s10:Options:~%25),t,"
|
||||
"@(y6:format)[02}${Po,@(y15:*skint-options*),@(y26:print-command-line-o"
|
||||
"ptions)[02}${'(s2:~%25),t,@(y6:format)[02}${'(s80:'--' ends options pr"
|
||||
"ocessing. Standalone FILE argument is treated as a script.~%25),t,@(y6"
|
||||
":format)[02}${'(s82:If no FILE is given, skint enters Read-Eval-Print "
|
||||
"loop (stdin>eval-print>stdout)~%25),t,@(y6:format)[02}'(s2:~%25),t,@(y"
|
||||
"6:format)[02}.!3${@(y12:command-line)[00}.!4${t,.7^d,,#0.8,.1,.9,.8,.("
|
||||
"i10),&5{%2:0,:1,:2,:3,:4,.6,&6{%3.1?{.1,.1,l2}{.0,l1},${.2,'(l1:y7:ver"
|
||||
"bose;),@(y11:sexp-match?)[02}?{t@!(y9:*verbose*)t,.4,:2^[42}${.2,'(l1:"
|
||||
"y5:quiet;),@(y11:sexp-match?)[02}?{t@!(y7:*quiet*)t,.4,:2^[42}${.2,'(l"
|
||||
"2:y13:append-libdir;y1:*;),@(y11:sexp-match?)[02}?{${.4,@(y20:append-l"
|
||||
"ibrary-path!)[01}t,.4,:2^[42}${.2,'(l2:y14:prepend-libdir;y1:*;),@(y11"
|
||||
":sexp-match?)[02}?{${.4,@(y21:prepend-library-path!)[01}t,.4,:2^[42}${"
|
||||
".2,'(l2:y14:define-feature;y1:*;),@(y11:sexp-match?)[02}?{${.4,:5^[01}"
|
||||
"t,.4,:2^[42}${.2,'(l2:y4:eval;y1:*;),@(y11:sexp-match?)[02}?{${t,.5,:4"
|
||||
"^[02}f,.4,:2^[42}${.2,'(l2:y6:script;y1:*;),@(y11:sexp-match?)[02}?{t@"
|
||||
"!(y7:*quiet*)${.5,.5,@(y10:run-script)[02},@(y4:exit)[41}${.2,'(l2:y7:"
|
||||
"program;y1:*;),@(y11:sexp-match?)[02}?{t@!(y7:*quiet*)${.5,.5,@(y11:ru"
|
||||
"n-program)[02},@(y4:exit)[41}${.2,'(l2:y9:benchmark;y1:*;),@(y11:sexp-"
|
||||
"match?)[02}?{${.5,.5,@(y10:run-script)[02},@(y4:exit)[41}${.2,'(l1:y7:"
|
||||
"version;),@(y11:sexp-match?)[02}?{${:3^[00}f,n,:2^[42}${.2,'(l1:y4:hel"
|
||||
"p;),@(y11:sexp-match?)[02}?{${:1^[00}f,n,:2^[42}${.2,'(l1:f;),@(y11:se"
|
||||
"xp-match?)[02}?{.3p?{t@!(y7:*quiet*)${.5d,.6a,@(y10:run-script)[02},@("
|
||||
"y4:exit)[41}:0~?{t,@(y4:exit)[41}f]4}]4},@(y15:*skint-options*),.2,@(y"
|
||||
"28:get-next-command-line-option)[23}.!0.0^_1[02}PiP09?{PoP09}{f}?{${@("
|
||||
"y15:*skint-version*),'(s30:SKINT Scheme Interpreter v~a~%25),t,@(y6:fo"
|
||||
"rmat)[03}${'(s35:Copyright (c) 2024 False Schemers~%25),t,@(y6:format)"
|
||||
"[02}}t]5",
|
||||
|
||||
0, 0, 0
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue