]> gitweb.factorcode.org Git - factor.git/blob - basis/command-line/startup/startup.factor
core: Add auto-use to syntax and add -ea parameter to factor command line.
[factor.git] / basis / command-line / startup / startup.factor
1 ! Copyright (C) 2011 Joe Groff.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: combinators command-line eval io io.pathnames kernel
4 layouts math math.parser namespaces parser system vocabs.loader ;
5 IN: command-line.startup
6
7 : help? ( -- ? )
8     "help" get "h" get or
9     os windows? [ script get "/?" = or ] when ;
10
11 : help. ( -- )
12 "Usage: " write vm-path file-name write " [options] [script] [arguments]
13
14 Options:
15     -help               print this message and exit
16     -version            print the Factor version and exit
17     -i=<image>          load Factor image file <image> [" write vm-path file-stem write ".image]
18     -run=<vocab>        run the MAIN: entry point of <vocab>
19         -run=listener   run terminal listener
20         -run=ui.tools   run Factor development UI
21     -e=<code>           evaluate <code>
22     -ea=<code>          evaluate <code> with auto-use
23     -no-user-init       suppress loading of .factor-rc
24     -datastack=<int>    datastack size in KiB [" write cell 32 * number>string write "]
25     -retainstack=<int>  retainstack size in KiB [" write cell 32 * number>string write "]
26     -callstack=<int>    callstack size in KiB [" write cell cpu ppc? 256 128 ? * number>string write "]
27     -callbacks=<int>    callback heap size in KiB [256]
28     -young=<int>        young gc generation 0 size in MiB [" write cell 4 / number>string write "]
29     -aging=<int>        aging gc generation 1 size in MiB [" write cell 2 / number>string write "]
30     -tenured=<int>      tenured gc generation 2 size in MiB [" write cell 24 * number>string write "]
31     -codeheap=<int>     codeheap size in MiB [64]
32     -pic=<int>          max pic size [3]
33     -fep                enter fep mode immediately
34     -no-signals         turn off OS signal handling
35     -roots=<paths>      '" write os windows? ";" ":" ? write "'-separated list of extra vocab root directories
36
37 Enter
38     \"command-line\" help
39 from within Factor for more information.
40 " write ;
41
42 : version? ( -- ? ) "version" get ;
43
44 : version. ( -- ) "Factor " write vm-version print ;
45
46 : command-line-startup ( -- )
47     (command-line) parse-command-line {
48         { [ help? ] [ help. ] }
49         { [ version? ] [ version. ] }
50         [
51             load-vocab-roots
52             run-user-init
53             "e" get "ea" get script get or or [
54                 "e" get [ eval( -- ) ] when*
55                 "ea" get [ t auto-use? [ eval( -- ) ] with-variable ] when*
56                 script get [ run-script ] when*
57             ] [
58                 "run" get run
59             ] if
60         ]
61     } cond
62
63     output-stream get [ stream-flush ] when*
64     0 exit ;