1 ! Copyright (C) 2003, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: init continuations hashtables io io.encodings.utf8
4 io.files io.pathnames kernel kernel.private namespaces parser
5 sequences strings system splitting vocabs.loader ;
11 : (command-line) ( -- args ) 10 getenv sift ;
13 : rc-path ( name -- path )
14 os windows? [ "." prepend ] unless
17 : run-bootstrap-init ( -- )
19 "factor-boot-rc" rc-path ?run-file
22 : run-user-init ( -- )
24 "factor-rc" rc-path ?run-file
27 : load-vocab-roots ( -- )
29 "factor-roots" rc-path dup exists? [
30 utf8 file-lines [ add-vocab-root ] each
34 : var-param ( name value -- ) swap set-global ;
36 : bool-param ( name -- ) "no-" ?head not var-param ;
39 "=" split1 [ var-param ] [ bool-param ] if* ;
41 : run-script ( file -- )
42 t "quiet" set-global run-file ;
44 : parse-command-line ( args -- )
45 [ command-line off script off ] [
47 [ param parse-command-line ]
48 [ script set command-line set ] if
51 SYMBOL: main-vocab-hook
53 : main-vocab ( -- vocab )
55 "alien.remote-control"
57 main-vocab-hook get [ call ] [ "listener" ] if*
60 : default-cli-args ( -- )
70 : ignore-cli-args? ( -- ? )
71 os macosx? "run" get "ui" = and ;
73 : script-mode ( -- ) ;
75 [ default-cli-args ] "command-line" add-init-hook