2006-05-15 01:01:47 -04:00
|
|
|
! Copyright (C) 2003, 2006 Slava Pestov.
|
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2006-08-25 00:02:30 -04:00
|
|
|
IN: command-line
|
|
|
|
|
USING: errors hashtables io kernel kernel-internals namespaces
|
2005-09-24 15:21:17 -04:00
|
|
|
parser sequences strings ;
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2019-10-18 09:05:04 -04:00
|
|
|
: ?run-file ( file -- )
|
|
|
|
|
dup exists? [ run-file ] [ drop ] if ;
|
|
|
|
|
|
2006-08-25 00:02:30 -04:00
|
|
|
: run-bootstrap-init ( -- )
|
|
|
|
|
"user-init" get [
|
2006-09-29 20:45:24 -04:00
|
|
|
home ".factor-boot-rc" path+ ?run-file
|
2006-08-25 00:02:30 -04:00
|
|
|
] when ;
|
|
|
|
|
|
2004-07-30 16:22:20 -04:00
|
|
|
: run-user-init ( -- )
|
2005-11-12 00:54:28 -05:00
|
|
|
"user-init" get [
|
2006-09-29 20:45:24 -04:00
|
|
|
home ".factor-rc" path+ ?run-file
|
2005-11-12 00:54:28 -05:00
|
|
|
] when ;
|
2004-07-30 16:22:20 -04:00
|
|
|
|
2006-05-15 01:01:47 -04:00
|
|
|
: cli-var-param ( name value -- ) swap set-global ;
|
2004-12-24 02:52:02 -05:00
|
|
|
|
2005-09-24 15:21:17 -04:00
|
|
|
: cli-bool-param ( name -- ) "no-" ?head not cli-var-param ;
|
2004-10-09 21:43:14 -04:00
|
|
|
|
2004-07-30 16:22:20 -04:00
|
|
|
: cli-param ( param -- )
|
2005-09-24 15:21:17 -04:00
|
|
|
"=" split1 [ cli-var-param ] [ cli-bool-param ] if* ;
|
2004-07-30 16:22:20 -04:00
|
|
|
|
|
|
|
|
: cli-arg ( argument -- argument )
|
2006-07-02 18:51:57 -04:00
|
|
|
"-" ?head [ cli-param f ] when ;
|
2004-07-30 16:22:20 -04:00
|
|
|
|
2004-12-25 02:55:03 -05:00
|
|
|
: cli-args ( -- args ) 10 getenv ;
|
|
|
|
|
|
2019-10-18 09:05:06 -04:00
|
|
|
: default-shell ( -- shell ) "tty" ;
|
2006-03-14 21:09:25 -05:00
|
|
|
|
2005-03-07 22:11:36 -05:00
|
|
|
: default-cli-args
|
2019-10-18 09:05:04 -04:00
|
|
|
"e" off
|
2005-03-07 22:11:36 -05:00
|
|
|
"user-init" on
|
|
|
|
|
"compile" on
|
2005-12-06 23:09:51 -05:00
|
|
|
"native-io" on
|
2019-10-18 09:05:04 -04:00
|
|
|
"quiet" off
|
2006-03-21 00:44:19 -05:00
|
|
|
macosx? "cocoa" set
|
|
|
|
|
unix? macosx? not and "x11" set
|
2006-03-14 21:09:25 -05:00
|
|
|
default-shell "shell" set ;
|
2005-03-07 22:11:36 -05:00
|
|
|
|
2006-07-02 18:51:57 -04:00
|
|
|
: ignore-cli-args? ( -- ? )
|
|
|
|
|
macosx? "shell" get "ui" = and ;
|
|
|
|
|
|
2004-12-25 02:55:03 -05:00
|
|
|
: parse-command-line ( -- )
|
2006-07-02 18:51:57 -04:00
|
|
|
cli-args [ cli-arg ] subset
|
2019-10-18 09:05:04 -04:00
|
|
|
ignore-cli-args? [ drop ] [ [ run-file ] each ] if
|
|
|
|
|
"e" get [ eval ] when* ;
|
|
|
|
|
|
|
|
|
|
IN: shells
|
|
|
|
|
|
|
|
|
|
: none ;
|