]> gitweb.factorcode.org Git - factor.git/blob - basis/command-line/command-line-docs.factor
merge project-euler.factor
[factor.git] / basis / command-line / command-line-docs.factor
1 USING: help.markup help.syntax parser vocabs.loader strings ;
2 IN: command-line
3
4 HELP: run-bootstrap-init
5 { $description "Runs the bootstrap initialization file in the user's home directory, unless the " { $snippet "-no-user-init" } " command line switch was given. This file is named " { $snippet ".factor-boot-rc" } " on Unix and " { $snippet "factor-boot-rc" } " on Windows." } ;
6
7 HELP: run-user-init
8 { $description "Runs the startup initialization file in the user's home directory, unless the " { $snippet "-no-user-init" } " command line switch was given. This file is named " { $snippet ".factor-rc" } " on Unix and " { $snippet "factor-rc" } " on Windows." } ;
9
10 HELP: load-vocab-roots
11 { $description "Loads the newline-separated list of additional vocabulary roots from the file named " { $snippet ".factor-roots" } " on Unix and " { $snippet "factor-roots" } " on Windows." } ;
12
13 HELP: param
14 { $values { "param" string } }
15 { $description "Process a command-line switch."
16 $nl
17 "If the parameter contains " { $snippet "=" } ", the global variable named by the string before the equals sign is set to the string after the equals sign."
18 $nl
19 "If the parameter begins with " { $snippet "no-" } ", sets the global variable named by the parameter with the prefix removed to " { $link f } "."
20 $nl
21 "Otherwise, sets the global variable named by the parameter to " { $link t } "." } ;
22
23 HELP: (command-line)
24 { $values { "args" "a sequence of strings" } }
25 { $description "Outputs the command line parameters which were passed to the Factor VM on startup." } ;
26
27 HELP: command-line
28 { $var-description "When Factor is run with a script, this variable contains command line parameters which follow the name of the script on the command line. In deployed applications, it contains the entire command line. In all other cases it is set to " { $link f } "." } ;
29
30 HELP: main-vocab-hook
31 { $var-description "Global variable holding a quotation which outputs a vocabulary name. UI backends set this so that the UI can automatically start if the prerequisites are met (for example, " { $snippet "$DISPLAY" } " being set on X11)." } ;
32
33 HELP: main-vocab
34 { $values { "vocab" string } }
35 { $description "Outputs the name of the vocabulary which is to be run on startup using the " { $link run } " word. The " { $snippet "-run" } " command line switch overrides this setting." } ;
36
37 HELP: default-cli-args
38 { $description "Sets global variables corresponding to default command line arguments." } ;
39
40 HELP: ignore-cli-args?
41 { $values { "?" "a boolean" } }
42 { $description "On Mac OS X, source files to run are supplied by the Cocoa API, so to avoid running them twice the startup code has to call this word." } ;
43
44 ARTICLE: "runtime-cli-args" "Command line switches for the VM"
45 "A handful of command line switches are processed by the VM and not the library. They control low-level features."
46 { $table
47     { { $snippet "-i=" { $emphasis "image" } } { "Specifies the image file to use; see " { $link "images" } } }
48     { { $snippet "-datastack=" { $emphasis "n" } } "Data stack size, kilobytes" }
49     { { $snippet "-retainstack=" { $emphasis "n" } } "Retain stack size, kilobytes" }
50     { { $snippet "-young=" { $emphasis "n" } } { "Size of youngest generation (0), megabytes" } }
51     { { $snippet "-aging=" { $emphasis "n" } } "Size of aging generation (1), megabytes" }
52     { { $snippet "-tenured=" { $emphasis "n" } } "Size of oldest generation (2), megabytes" }
53     { { $snippet "-codeheap=" { $emphasis "n" } } "Code heap size, megabytes" }
54     { { $snippet "-pic=" { $emphasis "n" } } "Maximum inline cache size. Setting of 0 disables inline caching, > 1 enables polymorphic inline caching" }
55     { { $snippet "-securegc" } "If specified, unused portions of the data heap will be zeroed out after every garbage collection" }
56 }
57 "If an " { $snippet "-i=" } " switch is not present, the default image file is used, which is usually a file named " { $snippet "factor.image" } " in the same directory as the runtime executable (on Windows and Mac OS X) or the current directory (on Unix)." ;
58
59 ARTICLE: "bootstrap-cli-args" "Command line switches for bootstrap"
60 "A number of command line switches can be passed to a bootstrap image to modify the behavior of the resulting image:"
61 { $table
62     { { $snippet "-output-image=" { $emphasis "image" } } { "Save the result to " { $snippet "image" } ". The default is " { $snippet "factor.image" } "." } }
63     { { $snippet "-no-user-init" } { "Inhibits the running of user initialization files on startup. See " { $link "rc-files" } "." } }
64     { { $snippet "-include=" { $emphasis "components..." } } "A list of components to include (see below)." }
65     { { $snippet "-exclude=" { $emphasis "components..." } } "A list of components to exclude." }
66     { { $snippet "-ui-backend=" { $emphasis "backend" } } { "One of " { $snippet "x11" } ", " { $snippet "windows" } ", or " { $snippet "cocoa" } ". The default is platform-specific." } }
67 }
68 "Bootstrap can load various optional components:"
69 { $table
70     { { $snippet "math" } "Rational and complex number support." }
71     { { $snippet "threads" } "Thread support." }
72     { { $snippet "compiler" } "The compiler." }
73     { { $snippet "tools" } "Terminal-based developer tools." }
74     { { $snippet "help" } "The help system." }
75     { { $snippet "help.handbook" } "The help handbook." }
76     { { $snippet "ui" } "The graphical user interface." }
77     { { $snippet "ui.tools" } "Graphical developer tools." }
78     { { $snippet "io" } "Non-blocking I/O and networking." }
79 }
80 "By default, all optional components are loaded. To load all optional components except for a given list, use the " { $snippet "-exclude=" } " switch; to only load specified optional components, use the " { $snippet "-include=" } "."
81 $nl
82 "For example, to build an image with the compiler but no other components, you could do:"
83 { $code "./factor -i=boot.macosx-ppc.image -include=compiler" }
84 "To build an image with everything except for the user interface and graphical tools,"
85 { $code "./factor -i=boot.macosx-ppc.image -exclude=\"ui ui.tools\"" }
86 "To generate a bootstrap image in the first place, see " { $link "bootstrap.image" } "." ;
87
88 ARTICLE: "standard-cli-args" "Command line switches for general usage"
89 "The following command line switches can be passed to a bootstrapped Factor image:"
90 { $table
91     { { $snippet "-e=" { $emphasis "code" } } { "This specifies a code snippet to evaluate. If you want Factor to exit immediately after, also specify " { $snippet "-run=none" } "." } }
92     { { $snippet "-run=" { $emphasis "vocab" } } { { $snippet { $emphasis "vocab" } } " is the name of a vocabulary with a " { $link POSTPONE: MAIN: } " hook to run on startup, for example " { $vocab-link "listener" } ", " { $vocab-link "ui" } " or " { $vocab-link "none" } "." } }
93     { { $snippet "-no-user-init" } { "Inhibits the running of user initialization files on startup. See " { $link "rc-files" } "." } }
94     { { $snippet "-quiet" } { "If set, " { $link run-file } " and " { $link require } " will not print load messages." } }
95 } ;
96
97 ARTICLE: "factor-boot-rc" "Bootstrap initialization file"
98 "The botstrap initialization file is named " { $snippet "factor-boot-rc" } " on Windows and " { $snippet ".factor-boot-rc" } " on Unix. This file can contain " { $link require } " calls for vocabularies you use frequently, and other such long-running tasks that you do not want to perform every time Factor starts."
99 $nl
100 "A word to run this file from an existing Factor session:"
101 { $subsections run-bootstrap-init }
102 "For example, if you changed " { $snippet ".factor-boot-rc" } " and do not want to bootstrap again, you can just invoke " { $link run-bootstrap-init } " in the listener." ;
103
104 ARTICLE: "factor-rc" "Startup initialization file"
105 "The startup initialization file is named " { $snippet "factor-rc" } " on Windows and " { $snippet ".factor-rc" } " on Unix. If it exists, it is run every time Factor starts."
106 $nl
107 "A word to run this file from an existing Factor session:"
108 { $subsections run-user-init } ;
109
110 ARTICLE: "factor-roots" "Additional vocabulary roots file"
111 "The vocabulary roots file is named " { $snippet "factor-roots" } " on Windows and " { $snippet ".factor-roots" } " on Unix. If it exists, it is loaded every time Factor starts. It contains a newline-separated list of " { $link "vocabs.roots" } "."
112 $nl
113 "A word to run this file from an existing Factor session:"
114 { $subsections load-vocab-roots } ;
115
116 ARTICLE: "rc-files" "Running code on startup"
117 "Factor looks for three optional files in your home directory."
118 { $subsections
119     "factor-boot-rc"
120     "factor-rc"
121     "factor-roots"
122 }
123 "The " { $snippet "-no-user-init" } " command line switch will inhibit loading running of these files."
124 $nl
125 "If you are unsure where the files should be located, evaluate the following code:"
126 { $code
127     "USE: command-line"
128     "\"factor-rc\" rc-path print"
129     "\"factor-boot-rc\" rc-path print"
130 }
131 "Here is an example " { $snippet ".factor-boot-rc" } " which sets up GVIM editor integration:"
132 { $code
133     "USING: editors.gvim namespaces ;"
134     "\"/opt/local/bin\" \\ gvim-path set-global"
135 } ;
136
137 ARTICLE: "cli" "Command line arguments"
138 "Factor command line usage:"
139 { $code "factor [VM args...] [script] [args...]" }
140 "Zero or more VM arguments can be passed in, followed by an optional script file name. If the script file is specified, it will be run on startup, any arguments after the script file are stored in the following variable, with no further processing by Factor itself:"
141 { $subsections command-line }
142 "Instead of running a script, it is also possible to run a vocabulary; this invokes the vocabulary's " { $link POSTPONE: MAIN: } " word:"
143 { $code "factor [system switches...] -run=<vocab name>" }
144 "If no script file or " { $snippet "-run=" } " switch is specified, Factor will start " { $link "listener" } " or " { $link "ui-tools" } ", depending on the operating system."
145 $nl
146 "As stated above, arguments in the first part of the command line, before the optional script name, are interpreted by to the Factor system. These arguments all start with a dash (" { $snippet "-" } ")."
147 $nl
148 "Switches can take one of the following three forms:"
149 { $list
150     { { $snippet "-" { $emphasis "foo" } } " - sets the global variable " { $snippet "\"" { $emphasis "foo" } "\"" } " to " { $link t } }
151     { { $snippet "-no-" { $emphasis "foo" } } " - sets the global variable " { $snippet "\"" { $emphasis "foo" } "\"" } " to " { $link f } }
152     { { $snippet "-" { $emphasis "foo" } "=" { $emphasis "bar" } } " - sets the global variable " { $snippet "\"" { $emphasis "foo" } "\"" } " to " { $snippet "\"" { $emphasis "bar" } "\"" } }
153 }
154 { $subsections
155     "runtime-cli-args"
156     "bootstrap-cli-args"
157     "standard-cli-args"
158 }
159 "The raw list of command line arguments can also be obtained and inspected directly:"
160 { $subsections (command-line) }
161 "There is a way to override the default vocabulary to run on startup, if no script name or " { $snippet "-run" } " switch is specified:"
162 { $subsections main-vocab-hook } ;
163
164 ABOUT: "cli"