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

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

Edit for clarity

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