(index ("command-line" 0) ("command-name" 1534) ("command-args" 2019) ("script-file" 2198) ("script-directory" 2545))
(def (sig (parameter "(command-line [string-list])" (id command-line))) (p "Like the standard " (tt "command-line") " procedure in R7RS and R6RS, this returns the command line as list of strings. The first element (always present) is the command name and the remaining elements (if any) are command arguments. Neither the strings nor the list should be mutated.") (p "Unlike RnRS " (tt "command-line") " this is a parameter that can be bound to another value, e.g. for subcommand processing. If the parameter is rebound to another list, the new list may share structure with the old list.") (p "The initial command line is more precisely specified than the value of RnRS " (tt "command-line") ":") (ul (li "When running a standalone program compiled by csc, the first element is the operating system's " (tt "argv[0]") " and the remaining elements are " (tt "argv[1]") " and up. However, any " (tt "-:") " arguments that give options for the Chicken runtime system are not part of the list.") (li "When running a script via " (tt "csi -script file.scm a b c") " or " (tt "csi -s file.scm a b c") " then " (tt "command-line") " is bound to " (tt "'(\"file.scm\" \"a\" \"b\" \"c\")") ".") (li "When not running a command, " (tt "command-line") " is bound to " (tt "'(\"\")") ". This happens when:" (ul (li "Loading source files into the " (tt "csi") " REPL via " (tt "csi file.scm") ".") (li "Loading source files into the " (tt "csi") " REPL via " (tt "(load \"file.scm\")") ".") (li "Evaluating code in the " (tt "csi") " REPL.")))))
(def (sig (procedure "(command-name)" (id command-name))) (p "Returns a simplified version of " (tt "(car (command-line))") ", respecting the current binding of the " (tt "command-line") " parameter.") (p "This is typically something suitable to display as the program name. For example, " (tt "/path/to/foo.scm") " is simplified into " (tt "foo") ".") (p "However, if " (tt "(car (command-line))") " is a zero-length string, " (tt "#f") " is returned to signify \"not a command\"."))
(def (sig (procedure "(command-args)" (id command-args))) (p "Returns " (tt "(cdr (command-line))") ", respecting the current binding of the " (tt "command-line") " parameter."))
(def (sig (parameter "(script-file [string?])" (id script-file))) (p "If running a source file as a script via " (tt "csi -script file.scm") " or " (tt "csi -s file.scm") ", returns an absolute pathname of that file as a string. Otherwise returns " (tt "#f") ".") (p "In Chicken, this is actually a parameter object and may be set by the user."))
(def (sig (procedure "(script-directory)" (id script-directory))) (p "Returns " (tt "(script-file)") " without the filename part, respecting the current binding of the " (tt "script-file") " parameter.") (p "The string ends with a directory separator so " (tt "string-append") " can be used to build pathnames to refer to files in the same directory as the script.") (p "Returns " (tt "#f") " in any situation where " (tt "(script-file)") " returns " (tt "#f") "."))
