Command line
Get an argument
Section titled “Get an argument”Given a file named “main.scm” with:
(import (scheme base) (scheme process-context))
(map write-string (command-line))When I successfully run stak main.scm hello
Then the stdout should contain “hello”.
Get two arguments
Section titled “Get two arguments”Given a file named “main.scm” with:
(import (scheme base) (scheme process-context))
(map write-string (command-line))When I successfully run stak main.scm hello world
Then the stdout should contain “hello”
And the stdout should contain “world”.
Get an argument at an index
Section titled “Get an argument at an index”Given a file named “main.scm” with:
(import (scheme base) (scheme cxr) (scheme process-context))
(write-string (<procedure> (command-line)))When I successfully run stak main.scm foo bar baz
Then the stdout should contain “<output>”.
Examples
Section titled “Examples”| procedure | output |
|---|---|
| cadr | foo |
| caddr | bar |
| cadddr | baz |
Options
Section titled “Options”Show a version
Section titled “Show a version”When I successfully run \<command\> --version
Then the stdout should contain “<command> “.
Examples
Section titled “Examples”| command |
|---|
| stak |
| stak-compile |
| stak-repl |
Set a heap size
Section titled “Set a heap size”Given a file named “main.scm” with:
(import (scheme base))When I run stak main.scm \<option\>
Then the exit status should be 1
And the stderr should contain “out of memory”.
Examples
Section titled “Examples”| option |
|---|
| -s 0 |
| –heap-size 0 |
Pass an option to a script
Section titled “Pass an option to a script”Given a file named “main.scm” with:
(import (scheme base) (scheme cxr) (scheme process-context))
(write-string (caddr (command-line)))When I successfully run stak main.scm -- --version
Then the stdout should contain exactly “–version”.