Skip to content

Commit ce9df1b

Browse files
committed
Add new format command
1 parent 7dde6a1 commit ce9df1b

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

src/Main.gren

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Terminal.Run
1616
import Terminal.Help
1717
import Terminal.Repl
1818
import Terminal.Report exposing (Report)
19+
import Terminal.Format
1920
import Compiler.Backend
2021
import Compiler.PackageName as PackageName exposing (PackageName)
2122
import Compiler.Paths
@@ -839,6 +840,13 @@ parseUserArgs model compilerPath =
839840
|> Task.onError endWithErrorString
840841
|> Task.perform RunCmd
841842

843+
CliParser.Format ->
844+
Terminal.Format.run
845+
{ stdout = model.stdout
846+
}
847+
|> Task.map (\_ -> Cmd.none)
848+
|> Task.perform RunCmd
849+
842850

843851
resolveProject : Model -> Task Report Terminal.PackageInstall.PackageResolution
844852
resolveProject model =

src/Terminal/Format.gren

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module Terminal.Format exposing
2+
( Config
3+
, run
4+
)
5+
6+
7+
import Stream
8+
import Stream.Log
9+
import Task exposing (Task)
10+
import Bytes exposing (Bytes)
11+
12+
13+
type alias Config =
14+
{ stdout : Stream.Writable Bytes
15+
}
16+
17+
18+
run : Config -> Task x {}
19+
run config =
20+
Stream.Log.line config.stdout "TODO"

src/Terminal/Parser.gren

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type Command
3131
| PackageDiff DiffArgs
3232
| Paths Paths.Options
3333
| Run RunOptions
34+
| Format
3435

3536

3637
type alias InitFlags =
@@ -203,6 +204,20 @@ parser =
203204
, builder =
204205
\_args flags -> Paths flags
205206
}
207+
|> CLI.Parser.withCommand
208+
{ word = "format"
209+
, arguments =
210+
CLI.Parser.noArgs
211+
, flags =
212+
CLI.Parser.noFlags
213+
, commonDescription = Nothing
214+
, summary =
215+
"Format Gren source code."
216+
, example =
217+
PP.empty
218+
, builder =
219+
\_args _flags -> Format
220+
}
206221
|> CLI.Parser.withCommand
207222
{ word = "make"
208223
, arguments =

0 commit comments

Comments
 (0)