mirror of
https://github.com/anoma/juvix.git
synced 2025-01-05 22:46:08 +03:00
3d012cc8fb
- Closes #1993 This pr makes it possible to use `~`, `..` and environment variables in the `juvix.yaml` and all flags / input of the cli. In the CLI, the shell will be responsible for replacing environment variables with their value, so the usual syntax can be used. For the `dependencies` field, I have implemented a parser that has some restrictions: 1. Environment variables are given with the makefile-like syntax `$(VAR)` 2. The three characters `$` `(` `)` are reserved for the environment variables syntax. They cannot be part of the path. 3. `~` is reserved for `$(HOME)`. I.e. the prepath `~~` will expand to `$HOME$HOME`. 4. Nested environment variables are not allowed. Thanks @paulcadman for the feedback. I think we are ready to merge this nightmarish pr 👻 --------- Co-authored-by: Paul Cadman <git@paulcadman.dev>
29 lines
1.0 KiB
Haskell
29 lines
1.0 KiB
Haskell
module Commands.Dev.Asm.Validate where
|
|
|
|
import Commands.Base
|
|
import Commands.Dev.Asm.Validate.Options
|
|
import Juvix.Compiler.Asm.Pretty qualified as Asm
|
|
import Juvix.Compiler.Asm.Transformation.Validate qualified as Asm
|
|
import Juvix.Compiler.Asm.Translation.FromSource qualified as Asm
|
|
|
|
runCommand :: forall r. (Members '[Embed IO, App] r) => AsmValidateOptions -> Sem r ()
|
|
runCommand opts = do
|
|
afile :: Path Abs File <- fromAppPathFile file
|
|
s <- embed (readFile (toFilePath afile))
|
|
case Asm.runParser (toFilePath afile) s of
|
|
Left err -> exitJuvixError (JuvixError err)
|
|
Right tab -> do
|
|
case Asm.validate' tab of
|
|
Just err ->
|
|
exitJuvixError (JuvixError err)
|
|
Nothing ->
|
|
if
|
|
| opts ^. asmValidateNoPrint ->
|
|
exitMsg ExitSuccess "validation succeeded"
|
|
| otherwise -> do
|
|
renderStdOut (Asm.ppOutDefault tab tab)
|
|
exitMsg ExitSuccess ""
|
|
where
|
|
file :: AppPath File
|
|
file = opts ^. asmValidateInputFile
|