SRFI 193

  1. SRFI 193
    1. Introduction
    2. Documentation
      1. Command
      2. Script
    3. Version History
    4. Author
    5. Repository
    6. License

Introduction

This egg implements SRFI 193: Command line.

Documentation

Command

[parameter] (command-line [string-list])

Like the standard 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.

Unlike RnRS 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.

The initial command line is more precisely specified than the value of RnRS command-line:

[procedure] (command-name)

Returns a simplified version of (car (command-line)), respecting the current binding of the command-line parameter.

This is typically something suitable to display as the program name. For example, /path/to/foo.scm is simplified into foo.

However, if (car (command-line)) is a zero-length string, #f is returned to signify "not a command".

[procedure] (command-args)

Returns (cdr (command-line)), respecting the current binding of the command-line parameter.

Script

[parameter] (script-file [string?])

If running a source file as a script via csi -script file.scm or csi -s file.scm, returns an absolute pathname of that file as a string. Otherwise returns #f.

In Chicken, this is actually a parameter object and may be set by the user.

[procedure] (script-directory)

Returns (script-file) without the filename part, respecting the current binding of the script-file parameter.

The string ends with a directory separator so string-append can be used to build pathnames to refer to files in the same directory as the script.

Returns #f in any situation where (script-file) returns #f.

Version History

Author

Lassi Kortela

Repository

https://github.com/lassik/chicken-srfi-193

License

 Copyright 2020 Lassi Kortela
 
 Permission to use, copy, modify, and distribute this software for any
 purpose with or without fee is hereby granted, provided that the above
 copyright notice and this permission notice appear in all copies.
 
 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
 WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
 AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 PERFORMANCE OF THIS SOFTWARE.