Command line handling cleanup
parent
33088f70bb
commit
f2ddbae4ac
|
@ -28,10 +28,7 @@ parser sequences strings ;
|
||||||
#! Handle a command-line argument. If the argument was
|
#! Handle a command-line argument. If the argument was
|
||||||
#! consumed, returns f. Otherwise returns the argument.
|
#! consumed, returns f. Otherwise returns the argument.
|
||||||
#! Parameters that start with + are runtime parameters.
|
#! Parameters that start with + are runtime parameters.
|
||||||
dup empty? [
|
"-" ?head [ cli-param f ] when ;
|
||||||
"-" ?head [ cli-param f ] when
|
|
||||||
dup [ "+" ?head [ drop f ] when ] when
|
|
||||||
] unless ;
|
|
||||||
|
|
||||||
: cli-args ( -- args ) 10 getenv ;
|
: cli-args ( -- args ) 10 getenv ;
|
||||||
|
|
||||||
|
@ -48,5 +45,11 @@ parser sequences strings ;
|
||||||
unix? macosx? not and "x11" set
|
unix? macosx? not and "x11" set
|
||||||
default-shell "shell" set ;
|
default-shell "shell" set ;
|
||||||
|
|
||||||
|
: ignore-cli-args? ( -- ? )
|
||||||
|
#! On Mac OS X, files to run are given to us via a Cocoa API
|
||||||
|
#! so we ignore any command line switches which name files.
|
||||||
|
macosx? "shell" get "ui" = and ;
|
||||||
|
|
||||||
: parse-command-line ( -- )
|
: parse-command-line ( -- )
|
||||||
cli-args [ cli-arg ] subset [ try-run-file ] each ;
|
cli-args [ cli-arg ] subset
|
||||||
|
ignore-cli-args? [ drop ] [ [ try-run-file ] each ] if ;
|
||||||
|
|
|
@ -4,11 +4,13 @@ IN: objc-classes
|
||||||
DEFER: FactorApplicationDelegate
|
DEFER: FactorApplicationDelegate
|
||||||
|
|
||||||
IN: cocoa
|
IN: cocoa
|
||||||
USING: arrays gadgets gadgets-listener hashtables kernel
|
USING: arrays gadgets gadgets-listener hashtables kernel memory
|
||||||
namespaces objc sequences errors freetype ;
|
namespaces objc sequences errors freetype ;
|
||||||
|
|
||||||
: finder-run-files ( alien -- )
|
: finder-run-files ( alien -- )
|
||||||
CF>string-array listener-run-files
|
#! We filter out the image name since that might be there on
|
||||||
|
#! first launch.
|
||||||
|
CF>string-array [ image = not ] subset listener-run-files
|
||||||
NSApp NSApplicationDelegateReplySuccess
|
NSApp NSApplicationDelegateReplySuccess
|
||||||
-> replyToOpenOrPrint: ;
|
-> replyToOpenOrPrint: ;
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,6 @@ namespaces sequences ;
|
||||||
|
|
||||||
TUPLE: help-gadget history ;
|
TUPLE: help-gadget history ;
|
||||||
|
|
||||||
: find-help-gadget [ help-gadget? ] find-parent ;
|
|
||||||
|
|
||||||
: show-help ( link help -- )
|
: show-help ( link help -- )
|
||||||
dup help-gadget-history add-history
|
dup help-gadget-history add-history
|
||||||
[ help-gadget-history set-model ] keep
|
[ help-gadget-history set-model ] keep
|
||||||
|
@ -16,6 +14,8 @@ TUPLE: help-gadget history ;
|
||||||
|
|
||||||
: go-home ( help -- ) "handbook" swap show-help ;
|
: go-home ( help -- ) "handbook" swap show-help ;
|
||||||
|
|
||||||
|
: find-help-gadget [ help-gadget? ] find-parent ;
|
||||||
|
|
||||||
: history-action find-help-gadget help-gadget-history ;
|
: history-action find-help-gadget help-gadget-history ;
|
||||||
|
|
||||||
: <help-toolbar> ( -- gadget )
|
: <help-toolbar> ( -- gadget )
|
||||||
|
|
|
@ -70,7 +70,11 @@ M: listener-gadget gadget-title drop "Listener" ;
|
||||||
[ call-listener ] ;
|
[ call-listener ] ;
|
||||||
|
|
||||||
: listener-run-files ( seq -- )
|
: listener-run-files ( seq -- )
|
||||||
[ [ run-file ] each ] curry listener-tool call-tool ;
|
dup empty? [
|
||||||
|
drop
|
||||||
|
] [
|
||||||
|
[ [ run-file ] each ] curry listener-tool call-tool
|
||||||
|
] if ;
|
||||||
|
|
||||||
M: input show ( input -- )
|
M: input show ( input -- )
|
||||||
input-string listener-tool call-tool ;
|
input-string listener-tool call-tool ;
|
||||||
|
|
28
vm/factor.c
28
vm/factor.c
|
@ -42,13 +42,13 @@ void usage(void)
|
||||||
{
|
{
|
||||||
printf("Usage: factor <image file> [ parameters ... ]\n");
|
printf("Usage: factor <image file> [ parameters ... ]\n");
|
||||||
printf("Runtime options -- n is a number:\n");
|
printf("Runtime options -- n is a number:\n");
|
||||||
printf(" +Dn Data stack size, kilobytes\n");
|
printf(" -D=n Data stack size, kilobytes\n");
|
||||||
printf(" +Rn Retain stack size, kilobytes\n");
|
printf(" -R=n Retain stack size, kilobytes\n");
|
||||||
printf(" +Cn Call stack size, kilobytes\n");
|
printf(" -C=n Call stack size, kilobytes\n");
|
||||||
printf(" +Gn Number of generations, must be >= 2\n");
|
printf(" -G=n Number of generations, must be >= 2\n");
|
||||||
printf(" +Yn Size of n-1 youngest generations, megabytes\n");
|
printf(" -Y=n Size of n-1 youngest generations, megabytes\n");
|
||||||
printf(" +An Size of tenured and semi-spaces, megabytes\n");
|
printf(" -A=n Size of tenured and semi-spaces, megabytes\n");
|
||||||
printf(" +Xn Code heap size, megabytes\n");
|
printf(" -X=n Code heap size, megabytes\n");
|
||||||
printf("Other options are handled by the Factor library.\n");
|
printf("Other options are handled by the Factor library.\n");
|
||||||
printf("See the documentation for details.\n");
|
printf("See the documentation for details.\n");
|
||||||
printf("Send bug reports to Slava Pestov <slava@factorcode.org>.\n");
|
printf("Send bug reports to Slava Pestov <slava@factorcode.org>.\n");
|
||||||
|
@ -74,13 +74,13 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
for(i = 1; i < argc; i++)
|
for(i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
if(factor_arg(argv[i],"+D%d",&ds_size)) continue;
|
if(factor_arg(argv[i],"-D=%d",&ds_size)) continue;
|
||||||
if(factor_arg(argv[i],"+R%d",&rs_size)) continue;
|
if(factor_arg(argv[i],"-R=%d",&rs_size)) continue;
|
||||||
if(factor_arg(argv[i],"+C%d",&cs_size)) continue;
|
if(factor_arg(argv[i],"-C=%d",&cs_size)) continue;
|
||||||
if(factor_arg(argv[i],"+G%d",&generations)) continue;
|
if(factor_arg(argv[i],"-G=%d",&generations)) continue;
|
||||||
if(factor_arg(argv[i],"+Y%d",&young_size)) continue;
|
if(factor_arg(argv[i],"-Y=%d",&young_size)) continue;
|
||||||
if(factor_arg(argv[i],"+A%d",&aging_size)) continue;
|
if(factor_arg(argv[i],"-A=%d",&aging_size)) continue;
|
||||||
if(factor_arg(argv[i],"+X%d",&code_size)) continue;
|
if(factor_arg(argv[i],"-X=%d",&code_size)) continue;
|
||||||
|
|
||||||
if(strncmp(argv[i],"+",1) == 0)
|
if(strncmp(argv[i],"+",1) == 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue