]> gitweb.factorcode.org Git - factor.git/blob - basis/command-line/startup/startup.factor
vm: remove -console option, seems not necessary.
[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 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     -no-user-init       suppress loading of .factor-rc
23     -datastack=<int>    datastack size in KiB [" write cell 32 * number>string write "]
24     -retainstack=<int>  retainstack size in KiB [" write cell 32 * number>string write "]
25     -callstack=<int>    callstack size in KiB [" write cell cpu ppc? 256 128 ? * number>string write "]
26     -callbacks=<int>    callback heap size in KiB [256]
27     -young=<int>        young gc generation 0 size in MiB [" write cell 4 / number>string write "]
28     -aging=<int>        aging gc generation 1 size in MiB [" write cell 2 / number>string write "]
29     -tenured=<int>      tenured gc generation 2 size in MiB [" write cell 24 * number>string write "]
30     -codeheap=<int>     codeheap size in MiB [64]
31     -pic=<int>          max pic size [3]
32     -fep                enter fep mode immediately
33     -no-signals         turn off OS signal handling
34     -roots=<paths>      '" write os windows? ";" ":" ? write "'-separated list of extra vocab root directories
35
36 Enter
37     \"command-line\" help
38 from within Factor for more information.
39 " write ;
40
41 : version? ( -- ? ) "version" get ;
42
43 : version. ( -- ) "Factor " write vm-version print ;
44
45 : command-line-startup ( -- )
46     (command-line) parse-command-line {
47         { [ help? ] [ help. ] }
48         { [ version? ] [ version. ] }
49         [
50             load-vocab-roots
51             run-user-init
52             "e" get script get or [
53                 "e" get [ eval( -- ) ] when*
54                 script get [ run-script ] when*
55             ] [
56                 "run" get run
57             ] if
58         ]
59     } cond
60
61     output-stream get [ stream-flush ] when*
62     0 exit ;