! Copyright (C) 2011 Joe Groff.
! See http://factorcode.org/license.txt for BSD license.
-USING: command-line eval io io.pathnames kernel namespaces
-sequences system vocabs.loader ;
+USING: combinators command-line eval io io.pathnames kernel
+namespaces system vocabs.loader ;
IN: command-line.startup
-: cli-usage ( -- )
+: help? ( -- ? )
+ "help" get "h" get or
+ os windows? [ script get "/?" = or ] when ;
+
+: help. ( -- )
"Usage: " write vm-path file-name write " [Factor arguments] [script] [script arguments]
Factor arguments:
-help print this message and exit
+ -version print the Factor version and exit
-i=<image> load Factor image file <image> (default " write vm-path file-stem write ".image)
-run=<vocab> run the MAIN: entry point of <vocab>
-run=listener run terminal listener
" write ;
-: help? ( -- ? )
- "help" get "h" get or
- os windows? [ script get "/?" = or ] when ;
+: version? ( -- ? ) "version" get ;
+
+: version. ( -- ) "Factor " write vm-version print ;
: command-line-startup ( -- )
- (command-line) parse-command-line
- help? [ cli-usage ] [
- load-vocab-roots
- run-user-init
- "e" get script get or [
- "e" get [ eval( -- ) ] when*
- script get [ run-script ] when*
- ] [
- "run" get run
- ] if
- ] if
+ (command-line) parse-command-line {
+ { [ help? ] [ help. ] }
+ { [ version? ] [ version. ] }
+ [
+ load-vocab-roots
+ run-user-init
+ "e" get script get or [
+ "e" get [ eval( -- ) ] when*
+ script get [ run-script ] when*
+ ] [
+ "run" get run
+ ] if
+ ]
+ } cond
output-stream get [ stream-flush ] when*
0 exit ;