Skip to content

Commit

Permalink
Update to Gren 24W.
Browse files Browse the repository at this point in the history
  • Loading branch information
robinheghan committed Dec 13, 2024
1 parent d4443d3 commit 3e5ac4a
Show file tree
Hide file tree
Showing 30 changed files with 4,214 additions and 2,850 deletions.
8 changes: 4 additions & 4 deletions cat/gren.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"source-directories": [
"src"
],
"gren-version": "0.4.5",
"gren-version": "0.5.0",
"dependencies": {
"direct": {
"gren-lang/core": "5.0.0",
"gren-lang/node": "4.0.0"
"gren-lang/core": "6.0.0",
"gren-lang/node": "5.0.0"
},
"indirect": {
"gren-lang/url": "4.0.0"
"gren-lang/url": "5.0.0"
}
}
}
16 changes: 8 additions & 8 deletions cat/src/Main.gren
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Main exposing (main)

import Node
import Bytes exposing (Bytes)
import Stream exposing (Stream)
import Stream
import Node exposing (Environment)
import FileSystem
import FileSystem.Path as Path
Expand All @@ -18,17 +18,17 @@ main =
init : Environment -> Init.Task (Cmd a)
init env =
Init.await FileSystem.initialize <| \fsPermission ->
case env.args of
when env.args is
[ _, _, file ] ->
FileSystem.readFile fsPermission (Path.fromPosixString file)
|> Task.map (Bytes.toString >> Maybe.withDefault "")
|> Task.onError (Task.succeed << FileSystem.errorToString)
|> Task.andThen (Stream.sendLine env.stdout)
|> Task.execute
|> Node.endWithCmd
|> Task.andThen (\str -> Stream.writeLineAsBytes str env.stdout)
|> Task.onError (\_ -> Task.succeed env.stdout)
|> Node.endSimpleProgram

_ ->
"Exactly one argument is required: the file name to read"
|> Stream.sendLine env.stderr
|> Task.execute
|> Node.endWithCmd
|> (\str -> Stream.writeLineAsBytes str env.stderr)
|> Task.onError (\_ -> Task.succeed env.stderr)
|> Node.endSimpleProgram
Loading

0 comments on commit 3e5ac4a

Please sign in to comment.