mirror of
https://github.com/nmattia/snack.git
synced 2024-11-24 04:04:35 +03:00
Add Ghci options (#163)
* Add Ghci options * Add ghci options test * Remove Build for test
This commit is contained in:
parent
7e3b61e4fc
commit
069f7d01fb
@ -234,7 +234,7 @@ parseSnackConfig = SnackConfig <$> Opts.optional
|
||||
data Command
|
||||
= Build
|
||||
| Run [String] -- Run with extra args
|
||||
| Ghci
|
||||
| Ghci [String]
|
||||
| Test
|
||||
| Hoogle
|
||||
|
||||
@ -245,7 +245,9 @@ parseCommand =
|
||||
<> Opts.command "run" (Opts.info
|
||||
( Run <$> Opts.many (Opts.argument Opts.str (Opts.metavar "ARG"))
|
||||
) mempty)
|
||||
<> Opts.command "ghci" (Opts.info (pure Ghci) mempty)
|
||||
<> Opts.command "ghci" (Opts.info
|
||||
( Ghci <$> Opts.many (Opts.argument Opts.str (Opts.metavar "ARG"))
|
||||
) mempty)
|
||||
<> Opts.command "hoogle" (Opts.info (pure Hoogle) mempty)
|
||||
)
|
||||
<|> Opts.hsubparser
|
||||
@ -460,7 +462,7 @@ runCommand :: SnackConfig -> PackageFile -> Command -> IO ()
|
||||
runCommand snackCfg packageFile = \case
|
||||
Build -> S.shelly $ void $ snackBuild snackCfg packageFile
|
||||
Run args -> quiet (snackBuild snackCfg packageFile) >>= runBuildResult args
|
||||
Ghci -> flip runExe [] =<<
|
||||
Ghci args -> flip runExe args =<<
|
||||
ghciExePath <$> (quiet (snackGhci snackCfg packageFile))
|
||||
Test -> noTest
|
||||
Hoogle -> flip runExe [ "server", "--local" ] =<<
|
||||
|
@ -48,6 +48,6 @@ rec {
|
||||
done
|
||||
fi
|
||||
done
|
||||
${ghc}/bin/ghci ${lib.strings.escapeShellArgs ghciArgs}
|
||||
${ghc}/bin/ghci ${lib.strings.escapeShellArgs ghciArgs} $@
|
||||
'';
|
||||
}
|
||||
|
5
tests/ghci-options/Main.hs
Normal file
5
tests/ghci-options/Main.hs
Normal file
@ -0,0 +1,5 @@
|
||||
module Main where
|
||||
|
||||
import Data.Text
|
||||
|
||||
main = putStrLn $ unpack "hello"
|
1
tests/ghci-options/golden
Normal file
1
tests/ghci-options/golden
Normal file
@ -0,0 +1 @@
|
||||
hello
|
4
tests/ghci-options/package.nix
Normal file
4
tests/ghci-options/package.nix
Normal file
@ -0,0 +1,4 @@
|
||||
{ main = "Main";
|
||||
src = ./.;
|
||||
dependencies = [ "text" ];
|
||||
}
|
6
tests/ghci-options/package.yaml
Normal file
6
tests/ghci-options/package.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
name: snack-extensions-test
|
||||
dependencies:
|
||||
- text
|
||||
executable:
|
||||
main: Main.hs
|
||||
source-dirs: .
|
16
tests/ghci-options/test
Executable file
16
tests/ghci-options/test
Executable file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim: ft=sh sw=2 et
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
test() {
|
||||
TMP_FILE=$(mktemp)
|
||||
|
||||
capture_io "$TMP_FILE" main | $SNACK ghci -- -XOverloadedStrings
|
||||
|
||||
diff golden $TMP_FILE
|
||||
rm $TMP_FILE
|
||||
}
|
||||
|
||||
SNACK="snack --package-file ./package.nix" test
|
||||
SNACK="snack --package-file ./package.yaml" test
|
Loading…
Reference in New Issue
Block a user