@@ -11,6 +11,7 @@ import Core
11
11
import File qualified
12
12
import Json qualified
13
13
import Neo.Build qualified as Build
14
+ import Neo.Run qualified as Run
14
15
import Task qualified
15
16
import Text qualified
16
17
@@ -23,6 +24,7 @@ data CommonFlags = CommonFlags
23
24
24
25
data NeoCommand
25
26
= Build CommonFlags
27
+ | Run CommonFlags
26
28
deriving (Show , Eq , Ord )
27
29
28
30
@@ -55,12 +57,19 @@ commandsParser = do
55
57
let build =
56
58
Command. CommandOptions
57
59
{ name = " build" ,
58
- description = " build a file or directory " ,
60
+ description = " build the project " ,
59
61
version = Nothing ,
60
62
decoder = buildParser
61
63
}
64
+ let run =
65
+ Command. CommandOptions
66
+ { name = " run" ,
67
+ description = " run the project" ,
68
+ version = Nothing ,
69
+ decoder = runParser
70
+ }
62
71
Command. commands
63
- (Array. fromLinkedList [build])
72
+ (Array. fromLinkedList [build, run ])
64
73
65
74
66
75
buildParser :: Command. OptionsParser NeoCommand
@@ -69,6 +78,12 @@ buildParser = do
69
78
pure (Build common)
70
79
71
80
81
+ runParser :: Command. OptionsParser NeoCommand
82
+ runParser = do
83
+ common <- flagsParser
84
+ pure (Run common)
85
+
86
+
72
87
flagsParser :: Command. OptionsParser CommonFlags
73
88
flagsParser = do
74
89
projectFilePath <-
@@ -85,6 +100,7 @@ flagsParser = do
85
100
86
101
data Error
87
102
= BuildError Build. Error
103
+ | RunError Run. Error
88
104
| Other
89
105
deriving (Show )
90
106
@@ -99,3 +115,12 @@ handleCommand command =
99
115
Ok config ->
100
116
Build. handle config
101
117
|> Task. mapError (\ e -> BuildError e)
118
+ Run flags -> do
119
+ txt <- File. readText flags. projectFile |> Task. mapError (\ _ -> Other )
120
+ case Json. decodeText txt of
121
+ Err err -> panic err
122
+ Ok config -> do
123
+ Build. handle config
124
+ |> Task. mapError (\ e -> BuildError e)
125
+ Run. handle config
126
+ |> Task. mapError (\ e -> RunError e)
0 commit comments