]> gitweb.factorcode.org Git - factor.git/blob - basis/command-line/startup/startup.factor
f3df3d7f1aa5fecf95965f27426a220c3f74bce2
[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: command-line eval io io.pathnames kernel namespaces
4 sequences system vocabs.loader ;
5 IN: command-line.startup
6
7 : cli-usage ( -- )
8 "Usage: " write vm-path file-name write " [Factor arguments] [script] [script arguments]
9
10 Common arguments:
11     -help               print this message and exit
12     -i=<image>          load Factor image file <image> (default " write vm-path file-stem write ".image)
13     -run=<vocab>        run the MAIN: entry point of <vocab>
14         -run=listener   run terminal listener
15         -run=ui.tools   run Factor development UI
16     -e=<code>           evaluate <code>
17     -no-user-init       suppress loading of .factor-rc
18     -datastack=<int>    datastack size in KB
19     -retainstack=<int>  retainstack size in KB
20     -callstack=<int>    callstack size in KB
21     -callbacks=<int>    callback heap size in KB
22     -young=<int>        young gc generation 0 size in MB
23     -aging=<int>        aging gc generation 1 size in MB
24     -tenured=<int>      tenured gc generation 2 size in MB
25     -codeheap=<int>     codeheap size in MB
26     -pic=<int>          max pic size
27     -fep                enter fep mode immediately
28     -nosignals          turn off OS signal handling
29     -console            open console if possible
30
31 Enter
32     \"command-line\" help
33 from within Factor for more information.
34
35 " write ;
36
37 : help? ( -- ? )
38     "help" get "-help" get or "h" get or
39     os windows? [ script get "/?" = ] [ f ] if or ;
40
41 : command-line-startup ( -- )
42     (command-line) parse-command-line
43     help? [ cli-usage ] [
44         load-vocab-roots
45         run-user-init
46         "e" get script get or [
47             "e" get [ eval( -- ) ] when*
48             script get [ run-script ] when*
49         ] [
50             "run" get run
51         ] if
52     ] if
53
54     output-stream get [ stream-flush ] when*
55     0 exit ;