source: project/wiki/eggref/5/srfi-193 @ 39068

Last change on this file since 39068 was 39068, checked in by lassik, 3 months ago

Initial version

File size: 3.3 KB
Line 
1[[tags: egg]]
2
3== SRFI 193
4
5[[toc:]]
6
7=== Introduction
8
9This egg implements
10[[https://srfi.schemers.org/srfi-193/srfi-193.html|SRFI 193: Command
11line]].
12
13=== Documentation
14
15==== Command
16
17<parameter>(command-line [string-list])</parameter>
18
19Like the standard {{command-line}} procedure in R7RS and R6RS, this
20gives the command line as list of strings, with the first element
21(always present) being the command name and the remaining elements (if
22any) are command arguments. Unlike RnRS {{command-line}}, this is a
23parameter that can be bound to another value by the Scheme programmer
24if desired, for example for subcommand processing.
25
26The value of this parameter should be a list of one or more strings at
27all times. Neither the strings nor the list should not be mutated. If
28the parameter is rebound to another list, the new list may share
29structure with the old list.
30
31The default value of the parameter is more precisely specified than
32the value of RnRS {{command-line}}. When evaluating code in the csi
33REPL, such as via {{load}}, the command line is a one-element list
34whose only element is a zero-length string.
35
36* When running a standalone program compiled via csi, the first
37element is the operating system's {{argv[0]}} and the remaining
38elements are {{argv[1]}} and up. However, {{-:}} arguments that control
39the Chicken runtime system are not part of the list.
40
41<procedure>(command-name)</procedure>
42
43Returns a simplified version of {{(car (command-line))}}, respecting
44the current binding of the {{command-line}} parameter. This is
45typically something suitable to display as the program name. For
46example, {{/path/to/foo.scm}} is simplified into {{foo}}.
47
48However, if {{(car (command-line))}} is a zero-length string (such as
49at the csi REPL), {{#f}} is returned to signify "not a command".
50
51<procedure>(command-args)</procedure>
52
53Returns {{(cdr (command-line))}}, respecting the current binding of
54the {{command-line}} parameter.
55
56==== Script
57
58<parameter>(script-file [string?])</parameter>
59
60If running a Scheme source file in csi, returns an absolute pathname
61of that file as a string. Otherwise returns {{#f}}.
62
63In Chicken, this is actually a parameter object and may be set by the
64user.
65
66<procedure>(script-directory)</procedure>
67
68Returns {{(script-file)}} without the filename part, respecting the
69current binding of the {{script-file}} parameter. Returns {{#f}} in
70any situation where {{(script-file)}} returns {{#f}}.
71
72Returned strings end with a directory separator so {{string-append}}
73can be used to build pathnames to refer to files in the same directory
74as the script.
75
76=== Version History
77
78* 0.1: First release.
79
80=== Author
81
82Lassi Kortela
83
84=== License
85
86  Copyright 2020 Lassi Kortela
87
88  Permission to use, copy, modify, and distribute this software for any
89  purpose with or without fee is hereby granted, provided that the above
90  copyright notice and this permission notice appear in all copies.
91
92  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
93  WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
94  WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
95  AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
96  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
97  PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
98  TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
99  PERFORMANCE OF THIS SOFTWARE.
Note: See TracBrowser for help on using the repository browser.