feat: read from std in

This commit is contained in:
2025-12-25 00:46:48 -05:00
parent 88ee4f799e
commit a56ec808ec
4 changed files with 22 additions and 1 deletions
+1 -1
View File
@@ -5,4 +5,4 @@ it:
@ chmod +x ${BINARY_NAME}
ex: it
@ ./lambda.exe -v "(\add.(add (add \f.\x.x)) \n.\f.\x.(f ((n f) x)))"
@ ./lambda.exe - < ./samples/simple.txt
+5
View File
@@ -20,6 +20,11 @@ func main() {
logger.Info("Using program arguments.", "args", os.Args)
logger.Info("Parsed CLI options.", "options", options)
if options.Input == "-" {
options.Input, err = cli.ReadInput()
cli.HandleError(err)
}
tokens, fails := tokenizer.GetTokens([]rune(options.Input))
if len(fails) > 0 {
cli.HandleError(errors.Join(fails...))
+15
View File
@@ -0,0 +1,15 @@
package cli
import (
"io"
"os"
)
func ReadInput() (string, error) {
data, err := io.ReadAll(os.Stdin)
if err != nil {
return "", err
}
return string(data), nil
}
+1
View File
@@ -0,0 +1 @@
(\add.(add (add (add \f.\x.x))) \n.\f.\x.(f ((n f) x)))