Use duck for util-io.

This commit is contained in:
Dominik Pantůček 2023-07-05 21:38:04 +02:00
parent 375c4ed857
commit 201093ab8c
5 changed files with 102 additions and 48 deletions

View file

@ -124,3 +124,62 @@ Returns a dictionary with the following keys:
Returns annotated source with information about originating commits
for each line.
## util-io [module]
(import util-io)
Module implementing advanced I/O.
### read-lines/no-bom [procedure]
(read-lines/no-bom ip)
* ```port``` - an input port
Reads lines using ```read-lines``` and if the first line contains
UTF-8 BOM, removes it.
### get-process-output-lines [procedure]
(get-process-output-lines cmd
. args)
* ```cmd``` - a string with the command
* ```args``` - list of arguments to pass to process
Returns a list of strings representing all the lines produced by
running the command given.
### get-process-exit+output-lines [procedure]
(get-process-exit+output-lines cmd
. args)
* ```cmd``` - a string with the command
* ```args``` - list of arguments to pass to process
Returns two values - an exit code and a list of strings representing
all the lines produced by running the command given.
### process-send/recv [procedure]
(process-send/recv cmd
args
. lines)
* ```cmd``` - a string with command
* ```args``` - list of arguments
* ```lines``` - lines to feed to stdin of the process
Executes given command ```cmd``` with given argument list ```args```
writing all ```lines``` to its standard input and then reads all the
process output.

View file

@ -139,45 +139,6 @@ Converts given number to a string with two-digit fractional
part. Should the fractional part be 0, it is replaced with the string
"--".
### IO
(import util-io)
Module implementing advanced I/O.
(read-lines/no-bom port)
* ```port``` - an input port
Reads lines using ```read-lines``` and if the first line contains
UTF-8 BOM, removes it.
(get-process-output-lines cmd . args)
* ```cmd``` - a string with the command
* ```args``` - list of arguments to pass to process
Returns a list of strings representing all the lines produced by
running the command given.
(get-process-exit+output-lines cmd . args)
* ```cmd``` - a string with the command
* ```args``` - list of arguments to pass to process
Returns two values - an exit code and a list of strings representing
all the lines produced by running the command given.
(process-send/recv cmd args . lines)
* ```cmd``` - a string with command
* ```args``` - list of arguments
* ```lines``` - lines to feed to stdin of the process
Executes given command ```cmd``` with given argument list ```args```
writing all ```lines``` to its standard input and then reads all the
process output.
### List
(import util-list)