]> gitweb.factorcode.org Git - factor.git/blob - basis/command-line/startup/startup.factor
Allow specifying vocabulary roots on the 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: 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     -roots=<paths>      a list of \"" write os windows? ";" ":" ? write "\"-delimited extra vocab roots
31
32 Enter
33     \"command-line\" help
34 from within Factor for more information.
35
36 " write ;
37
38 : help? ( -- ? )
39     "help" get "-help" get or "h" get or
40     os windows? [ script get "/?" = ] [ f ] if or ;
41
42 : command-line-startup ( -- )
43     (command-line) parse-command-line
44     help? [ cli-usage ] [
45         load-vocab-roots
46         run-user-init
47         "e" get script get or [
48             "e" get [ eval( -- ) ] when*
49             script get [ run-script ] when*
50         ] [
51             "run" get run
52         ] if
53     ] if
54
55     output-stream get [ stream-flush ] when*
56     0 exit ;