]> gitweb.factorcode.org Git - factor.git/commitdiff
command-line: moving run-script to command-line.startup
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 4 Feb 2022 06:03:16 +0000 (22:03 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 4 Feb 2022 06:03:16 +0000 (22:03 -0800)
basis/command-line/command-line-docs.factor
basis/command-line/command-line.factor
basis/command-line/startup/startup.factor

index 82ffe45e2b6b08612eaab016a6d3c645c1aed950..14fc2c3c2d1281f356f5167899a9d12795e09781 100644 (file)
@@ -134,7 +134,7 @@ $nl
 ARTICLE: "command-line" "Command line arguments"
 "Factor command line usage:"
 { $code "factor [options] [script] [arguments]" }
-"Zero or more options can be passed in, followed by an optional script file name. If the script file is specified, it will be run on startup using " { $link run-script } ". Any arguments after the script file are stored in the following variable, with no further processing by Factor itself:"
+"Zero or more options can be passed in, followed by an optional script file name. If the script file is specified, it will be run on startup. Any arguments after the script file are stored in the following variable, with no further processing by Factor itself:"
 { $subsections command-line }
 "Instead of running a script, it is also possible to run a vocabulary; this invokes the vocabulary's " { $link POSTPONE: MAIN: } " word:"
 { $code "factor [system switches...] -run=<vocab name>" }
@@ -158,9 +158,4 @@ $nl
 "There is a way to override the default vocabulary to run on startup, if no script name or " { $snippet "-run" } " switch is specified:"
 { $subsections main-vocab-hook } ;
 
-HELP: run-script
-{ $values { "file" "a pathname string" } }
-{ $description "Parses the Factor source code stored in a file and runs it. The initial vocabulary search path is used. If the source file contains a " { $link POSTPONE: MAIN: } " declaration, the main entry point of the file will be also be executed. Loading messages will be suppressed." }
-{ $errors "Throws an error if loading the file fails, there input is malformed, or if a runtime error occurs while calling the parsed quotation or executing the main entry point." } ;
-
 ABOUT: "command-line"
index 55872fd4cfb274e2c6713998280763f41349093a..3aff5d8c34cb01e1dcac93245f917a4eb5c5fef1 100644 (file)
@@ -1,9 +1,8 @@
 ! Copyright (C) 2003, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.strings assocs combinators.smart
-continuations io io.encodings.utf8 io.files kernel
-kernel.private namespaces parser parser.notes prettyprint
-sequences source-files source-files.errors splitting system
+USING: accessors alien.strings assocs continuations
+io.encodings.utf8 io.files kernel kernel.private namespaces
+parser sequences source-files.errors splitting system
 vocabs.loader ;
 IN: command-line
 
@@ -63,17 +62,6 @@ SYMBOL: command-line
 : param ( param -- )
     "=" split1 [ var-param ] [ bool-param ] if* ;
 
-: run-script ( file -- )
-    t parser-quiet? [
-        [
-            parse-file [
-                output>array
-                [ nl "--- Data stack:" print stack. ] unless-empty
-            ] call( quot --  )
-        ]
-        [ path>source-file main>> [ execute( -- ) ] when* ] bi
-    ] with-variable ;
-
 : (parse-command-line) ( args -- )
     [
         unclip "-" ?head [
index f4805406b56caaa2d2c54e02d9abbeaa3498976a..67de6583d8d9cb0113f3b83a80e2ff858c4844b1 100644 (file)
@@ -1,8 +1,9 @@
 ! Copyright (C) 2011 Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: combinators command-line eval io io.pathnames kernel
-layouts math math.parser namespaces parser system vocabs.loader
-;
+USING: accessors combinators combinators.smart command-line eval
+io io.pathnames kernel layouts math math.parser namespaces
+parser parser.notes prettyprint sequences source-files system
+vocabs.loader ;
 IN: command-line.startup
 
 : help? ( -- ? )
@@ -41,6 +42,17 @@ from within Factor for more information.
 
 : version? ( -- ? ) "version" get ;
 
+: run-script ( file -- )
+    t parser-quiet? [
+        [
+            parse-file [
+                output>array
+                [ nl "--- Data stack:" print stack. ] unless-empty
+            ] call( quot --  )
+        ]
+        [ path>source-file main>> [ execute( -- ) ] when* ] bi
+    ] with-variable ;
+
 : command-line-startup ( -- )
     (command-line) parse-command-line {
         { [ help? ] [ help. ] }