on master help sign in
Weaken types of commands again
commit9e69a03f72f6fc32897237817c63cfbb53dcb327 authorTom Smalley <tfsmalley@gmail.com> dateWed 6 May 2020, 14:36 (6 years ago) parentac8db40
4 files changed+16−16
lib/cliapp/src/Obelisk/CliApp/Process.hs+1−1 lib/command/src/Obelisk/Command.hs+6−6 lib/command/src/Obelisk/Command/Project.hs+5−5 lib/command/src/Obelisk/Command/Run.hs+4−4
lib/cliapp/src/Obelisk/CliApp/Process.hs+1−1
@@ -55,7 +55,7 @@ import qualified System.IO.Streams as Streams
5555import System.IO.Streams.Concurrent (concurrentMerge)
5656import System.Process (CreateProcess, ProcessHandle, StdStream (CreatePipe), std_err, std_out)
5757import qualified System.Process as Process
58−import Text.ShellEscape (bytes, bash)
58+import Text.ShellEscape (bash, bytes)
5959import qualified Data.Aeson as Aeson
6060
6161import Control.Monad.Log (Severity (..))
lib/command/src/Obelisk/Command.hs+6−6
@@ -23,7 +23,7 @@ import System.Environment
2323import System.FilePath
2424import qualified System.Info
2525import System.IO (hIsTerminalDevice, stdout)
26−import Text.ShellEscape (Bash, bash)
26+import Text.ShellEscape (bash, bytes)
2727import System.Posix.Process (executeFile)
2828
2929import Obelisk.App
@@ -400,11 +400,11 @@ ob = \case
400400 ObCommand_Repl interpretPathsList -> withInterpretPaths interpretPathsList runRepl
401401 ObCommand_Watch interpretPathsList -> withInterpretPaths interpretPathsList runWatch
402402 ObCommand_Shell (ShellOpts shellAttr interpretPathsList cmd) -> withInterpretPaths interpretPathsList $ \root interpretPaths ->
403− nixShellForInterpretPaths False shellAttr root interpretPaths (pure . bash . BSU.fromString <$> cmd)
403+ nixShellForInterpretPaths False shellAttr root interpretPaths (BSU.toString . bytes . bash . BSU.fromString <$> cmd)
404404 ObCommand_Doc shellAttr pkgs -> withInterpretPaths [] $ \root interpretPaths ->
405− nixShellForInterpretPaths True shellAttr root interpretPaths $ Just [haddockCommand pkgs]
405+ nixShellForInterpretPaths True shellAttr root interpretPaths $ Just $ haddockCommand pkgs
406406 ObCommand_Hoogle shell' port -> withProjectRoot "." $ \root -> do
407− nixShellWithHoogle root True shell' $ Just $ fmap (bash . BSU.fromString) ["hoogle", "server", "-p", show port, "--local"]
407+ nixShellWithHoogle root True shell' $ Just $ "hoogle server -p" <> show port <> " --local"
408408 ObCommand_Internal icmd -> case icmd of
409409 ObInternal_ApplyPackages origPath inPath outPath packagePaths -> do
410410 liftIO $ Preprocessor.applyPackages origPath inPath outPath packagePaths
@@ -420,8 +420,8 @@ withInterpretPaths interpretPathsList f = withProjectRoot "." $ \root -> do
420420 Nothing -> failWith "No paths provided for finding packages"
421421 Just interpretPaths -> f root interpretPaths
422422
423−haddockCommand :: [String] -> Bash
424−haddockCommand pkgs = bash $ BSU.fromString $ unwords
423+haddockCommand :: [String] -> String
424+haddockCommand pkgs = unwords
425425 [ "for p in"
426426 , unwords [getHaddockPath p ++ "/index.html" | p <- pkgs]
427427 , "; do echo $p; done"
lib/command/src/Obelisk/Command/Project.hs+5−5
@@ -40,7 +40,7 @@ import System.IO.Temp
4040import System.IO.Unsafe (unsafePerformIO)
4141import System.Posix (FileStatus, FileMode, CMode (..), UserID, deviceID, fileID, fileMode, fileOwner, getFileStatus, getRealUserID)
4242import System.Posix.Files
43−import Text.ShellEscape (Bash, bytes, bash)
43+import Text.ShellEscape (bash, bytes)
4444
4545import GitHub.Data.GitData (Branch)
4646import GitHub.Data.Name (Name)
@@ -272,7 +272,7 @@ filePermissionIsSafe s umask = not fileWorldWritable && fileGroupWritable <= uma
272272 fileGroupWritable = fileMode s .&. 0o020 == 0o020
273273 umaskGroupWritable = umask .&. 0o020 == 0
274274
275−nixShellRunConfig :: MonadObelisk m => FilePath -> Bool -> Maybe [Bash] -> m NixShellConfig
275+nixShellRunConfig :: MonadObelisk m => FilePath -> Bool -> Maybe String -> m NixShellConfig
276276nixShellRunConfig root isPure command = do
277277 nixpkgsPath <- fmap T.strip $ readProcessAndLogStderr Debug $ setCwd (Just root) $
278278 proc nixExePath ["eval", "(import .obelisk/impl {}).nixpkgs.path"]
@@ -283,7 +283,7 @@ nixShellRunConfig root isPure command = do
283283 & nixShellConfig_run .~ (command <&> \cs -> unwords $ concat
284284 [ ["export", BSU.toString . bytes . bash $ "NIX_PATH=nixpkgs=" <> encodeUtf8 nixpkgsPath, ";"]
285285 , maybe [] (\v -> ["export", BSU.toString . bytes . bash $ "NIX_REMOTE=" <> encodeUtf8 (T.pack v), ";"]) nixRemote
286− , fmap (BSU.toString . bytes) cs
286+ , [cs]
287287 ])
288288
289289nixShellRunProc :: NixShellConfig -> ProcessSpec
@@ -296,7 +296,7 @@ nixShellWithoutPkgs
296296 -> Bool -- ^ Should we chdir to the package root in the shell?
297297 -> Map Text FilePath -- ^ Package names mapped to their paths
298298 -> String -- ^ Shell attribute to use (e.g. @"ghc"@, @"ghcjs"@, etc.)
299− -> Maybe [Bash] -- ^ If 'Just' run the given command; otherwise just open the interactive shell
299+ -> Maybe String -- ^ If 'Just' run the given command; otherwise just open the interactive shell
300300 -> m ()
301301nixShellWithoutPkgs root isPure chdirToRoot packageNamesAndPaths shellAttr command = do
302302 packageNamesAndAbsPaths <- liftIO $ for packageNamesAndPaths makeAbsolute
@@ -314,7 +314,7 @@ nixShellWithoutPkgs root isPure chdirToRoot packageNamesAndPaths shellAttr comma
314314 ]
315315 void $ waitForProcess ph
316316
317−nixShellWithHoogle :: MonadObelisk m => FilePath -> Bool -> String -> Maybe [Bash] -> m ()
317+nixShellWithHoogle :: MonadObelisk m => FilePath -> Bool -> String -> Maybe String -> m ()
318318nixShellWithHoogle root isPure shell' command = do
319319 defShellConfig <- nixShellRunConfig root isPure command
320320 (_, _, _, ph) <- createProcess_ "nixShellWithHoogle" $ setCwd (Just root) $ nixShellRunProc $ defShellConfig
lib/command/src/Obelisk/Command/Run.hs+4−4
@@ -61,7 +61,7 @@ import System.Environment (getExecutablePath)
6161import System.FilePath
6262import qualified System.Info
6363import System.IO.Temp (withSystemTempDirectory)
64−import Text.ShellEscape (Bash, bash)
64+import Text.ShellEscape (bash, bytes)
6565
6666import Obelisk.App (MonadObelisk)
6767import Obelisk.CliApp (
@@ -195,7 +195,7 @@ exportGhciConfig useRelativePaths root interpretPaths = do
195195 pkgs <- getParsedLocalPkgs root interpretPaths
196196 getGhciSessionSettings pkgs "." useRelativePaths
197197
198−nixShellForInterpretPaths :: MonadObelisk m => Bool -> String -> FilePath -> PathTree Interpret -> Maybe [Bash] -> m ()
198+nixShellForInterpretPaths :: MonadObelisk m => Bool -> String -> FilePath -> PathTree Interpret -> Maybe String -> m ()
199199nixShellForInterpretPaths isPure shell root interpretPaths cmd = do
200200 pkgs <- getParsedLocalPkgs root interpretPaths
201201 nixShellWithoutPkgs root isPure False (packageInfoToNamePathMap pkgs) shell cmd
@@ -466,7 +466,7 @@ runGhciRepl root (toList -> packages) ghciArgs =
466466 -- NOTE: We do *not* want to use $(staticWhich "ghci") here because we need the
467467 -- ghc that is provided by the shell in the user's project.
468468 nixShellWithoutPkgs root True False (packageInfoToNamePathMap packages) "ghc" $
469− Just $ fmap (bash . BSU.fromString) $ "ghci" : ghciArgs
469+ Just $ unwords $ fmap (BSU.toString . bytes . bash . BSU.fromString) $ "ghci" : ghciArgs
470470
471471-- | Run ghcid
472472runGhcid
@@ -479,7 +479,7 @@ runGhcid
479479 -> m ()
480480runGhcid root chdirToRoot ghciArgs (toList -> packages) mcmd =
481481 nixShellWithoutPkgs root True chdirToRoot (packageInfoToNamePathMap packages) "ghc" $
482− Just $ fmap (bash . BSU.fromString) $ ghcidExePath : opts
482+ Just $ unwords $ fmap (BSU.toString . bytes . bash . BSU.fromString) $ ghcidExePath : opts
483483 where
484484 opts = concat
485485 [ ["-W"]