diff --git a/basis/command-line/startup/startup.factor b/basis/command-line/startup/startup.factor index 5d5fca126c..3f976028a9 100644 --- a/basis/command-line/startup/startup.factor +++ b/basis/command-line/startup/startup.factor @@ -1,14 +1,19 @@ ! 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= load Factor image file (default " write vm-path file-stem write ".image) -run= run the MAIN: entry point of -run=listener run terminal listener @@ -35,22 +40,25 @@ from within Factor for more information. " 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 ;