mirror of
https://github.com/anoma/juvix.git
synced 2024-12-24 07:57:58 +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>
27 lines
1.2 KiB
Haskell
27 lines
1.2 KiB
Haskell
module Commands.Dev.Core.Strip where
|
|
|
|
import Commands.Base
|
|
import Commands.Dev.Core.Strip.Options
|
|
import Juvix.Compiler.Core.Options qualified as Core
|
|
import Juvix.Compiler.Core.Pipeline qualified as Core
|
|
import Juvix.Compiler.Core.Pretty qualified as Core
|
|
import Juvix.Compiler.Core.Translation.FromSource qualified as Core
|
|
import Juvix.Compiler.Core.Translation.Stripped.FromCore qualified as Stripped
|
|
|
|
runCommand :: forall r a. (Members '[Embed IO, App] r, CanonicalProjection a Core.Options, CanonicalProjection a CoreStripOptions) => a -> Sem r ()
|
|
runCommand opts = do
|
|
gopts <- askGlobalOptions
|
|
inputFile :: Path Abs File <- fromAppPathFile sinputFile
|
|
s' <- embed (readFile $ toFilePath inputFile)
|
|
(tab, _) <- getRight (mapLeft JuvixError (Core.runParser inputFile Core.emptyInfoTable s'))
|
|
let r =
|
|
run $
|
|
runReader (project gopts) $
|
|
runError @JuvixError (Core.toStripped' tab :: Sem '[Error JuvixError, Reader Core.CoreOptions] Core.InfoTable)
|
|
tab' <- getRight $ mapLeft JuvixError $ mapRight Stripped.fromCore r
|
|
unless (project opts ^. coreStripNoPrint) $ do
|
|
renderStdOut (Core.ppOut opts tab')
|
|
where
|
|
sinputFile :: AppPath File
|
|
sinputFile = project opts ^. coreStripInputFile
|