]> gitweb.factorcode.org Git - factor.git/commitdiff
command-line: save the executable in a variable so that people don't use (command...
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 23 Dec 2014 16:12:31 +0000 (08:12 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 23 Dec 2014 16:12:31 +0000 (08:12 -0800)
basis/bootstrap/finish-staging.factor
basis/bootstrap/stage2.factor
basis/command-line/command-line-docs.factor
basis/command-line/command-line-tests.factor
basis/command-line/command-line.factor
basis/command-line/startup/startup.factor
basis/tools/deploy/shaker/shaker.factor

index 5dd6d4cd53883297b6f3e281d8cbc00f27df1be5..b4e8926aa82c57b078384e77f3f9ca476b3755f3 100644 (file)
@@ -4,7 +4,7 @@ vocabs.loader ;
 [
     boot
     do-startup-hooks
-    (command-line) rest parse-command-line
+    (command-line) parse-command-line
     "run" get run
     output-stream get [ stream-flush ] when*
     0 exit
index f74e577220e62edaf850f563530a837e570fd766..15872ce4997f30bf8b1651e953d7e197c1537a12 100644 (file)
@@ -71,7 +71,7 @@ SYMBOL: bootstrap-time
 
     strip-encodings
 
-    (command-line) rest parse-command-line
+    (command-line) parse-command-line
 
     ! Set dll paths
     os windows? [ "windows" require ] when
index fa6310a92d3a02cbaecf0627bbb5c5d1464b5961..66263afebfef280e384cbb129bf111b227662cab 100644 (file)
@@ -23,10 +23,17 @@ $nl
 
 HELP: (command-line)
 { $values { "args" "a sequence of strings" } }
-{ $description "Outputs the command line parameters which were passed to the Factor VM on startup." } ;
+{ $description "Outputs the raw command line parameters which were passed to the Factor VM on startup."
+$nl
+"We recommend using the " { $link executable } " and " { $link command-line } " symbols instead." } ;
 
 HELP: command-line
-{ $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 } "." } ;
+{ $var-description "When Factor is run with a script, this variable contains the list of command line arguments which follow the name of the script on the command line. In deployed applications, it contains the full list of command line arguments. In all other cases it is set to " { $link f } "." }
+{ $see-also executable } ;
+
+HELP: executable
+{ $var-description "Provides the path to the executable binary, typically Factor.  However, in a deployed application this will be the path to the deployed binary that is being executed." }
+{ $see-also command-line } ;
 
 HELP: main-vocab-hook
 { $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)." } ;
index 01099ae19d1a7ee52a14b7fd0982123e6d724898..36943a2a58e1c3f98af0de8dc16dad50b1cb2401 100644 (file)
@@ -1,32 +1,32 @@
 USING: namespaces splitting tools.test ;
 IN: command-line
 
-{ f { "a" "b" "c" } } [
-    { "-run=test-voc" "a" "b" "c" } parse-command-line
-    script get command-line get
+{ "factor" f { "a" "b" "c" } } [
+    { "factor" "-run=test-voc" "a" "b" "c" } parse-command-line
+    executable get script get command-line get
 ] unit-test
 
-{ f { "-a" "b" "c" } } [
-    { "-run=test-voc" "-a" "b" "c" } parse-command-line
-    script get command-line get
+{ "factor" f { "-a" "b" "c" } } [
+    { "factor" "-run=test-voc" "-a" "b" "c" } parse-command-line
+    executable get script get command-line get
 ] unit-test
 
-{ f { "a" "-b" "c" } } [
-    { "-run=test-voc" "a" "-b" "c" } parse-command-line
-    script get command-line get
+{ "factor" f { "a" "-b" "c" } } [
+    { "factor" "-run=test-voc" "a" "-b" "c" } parse-command-line
+    executable get script get command-line get
 ] unit-test
 
-{ f { "a" "b" "-c" } } [
-    { "-run=test-voc" "a" "b" "-c" } parse-command-line
-    script get command-line get
+{ "factor" f { "a" "b" "-c" } } [
+    { "factor" "-run=test-voc" "a" "b" "-c" } parse-command-line
+    executable get script get command-line get
 ] unit-test
 
-{ "a" { "b" "c" } } [
-    { "a" "b" "c" } parse-command-line
-    script get command-line get
+{ "factor" "a" { "b" "c" } } [
+    { "factor" "a" "b" "c" } parse-command-line
+    executable get script get command-line get
 ] unit-test
 
-{ "a" { "b" "c" } } [
-    { "-foo" "a" "b" "c" } parse-command-line
-    script get command-line get
+{ "factor" "a" { "b" "c" } } [
+    { "factor" "-foo" "a" "b" "c" } parse-command-line
+    executable get script get command-line get
 ] unit-test
index 37511dae90c5473d96da4c22cdd06aebff611658..7026abd19c175b1b3a621ae0167ae61473d826b0 100644 (file)
@@ -18,6 +18,7 @@ M: user-init-error error-file file>> ;
 M: user-init-error error-line line#>> ;
 M: user-init-error error-type drop +user-init-error+ ;
 
+SYMBOL: executable
 SYMBOL: script
 SYMBOL: command-line
 
@@ -76,6 +77,7 @@ SYMBOL: command-line
 : parse-command-line ( args -- )
     command-line off
     script off
+    unclip executable set
     (parse-command-line) ;
 
 SYMBOL: main-vocab-hook
index a93bf2763fb5e974dc65cd0cb07b06a16b74f675..2a77de3692ec7e9b2eb3f62dedfbab4336e24dbd 100644 (file)
@@ -28,7 +28,7 @@ from within Factor for more information.
     os windows? [ script get "/?" = ] [ f ] if or ;
 
 : command-line-startup ( -- )
-    (command-line) rest parse-command-line
+    (command-line) parse-command-line
     help? [ cli-usage ] [
         load-vocab-roots
         run-user-init
index b4eaffadbf8ea8793df17474651eacfdc02e54bd..4610e2b54725168d3b65215e8e694e33d64931ac 100755 (executable)
@@ -32,8 +32,11 @@ IN: tools.deploy.shaker
 ! This file is some hairy shit.
 
 : add-command-line-hook ( -- )
-    [ (command-line) rest command-line set-global ] "command-line"
-    startup-hooks get set-at ;
+    [
+        (command-line) unclip
+        executable set-global
+        command-line set-global
+    ] "command-line" startup-hooks get set-at ;
 
 : strip-startup-hooks ( -- )
     "Stripping startup hooks" show