on master help sign in
Weaken types of commands again
9e69a03Tom Smalley
lib/cliapp/src/Obelisk/CliApp/Process.hs+1−1
@@ -55,7 +55,7 @@ import qualified System.IO.Streams as Streams
55import System.IO.Streams.Concurrent (concurrentMerge)
55import System.IO.Streams.Concurrent (concurrentMerge)
56import System.Process (CreateProcess, ProcessHandle, StdStream (CreatePipe), std_err, std_out)
56import System.Process (CreateProcess, ProcessHandle, StdStream (CreatePipe), std_err, std_out)
57import qualified System.Process as Process
57import qualified System.Process as Process
58−import Text.ShellEscape (bytes, bash)
58+import Text.ShellEscape (bash, bytes)
59import qualified Data.Aeson as Aeson
59import qualified Data.Aeson as Aeson
60
60
61import Control.Monad.Log (Severity (..))
61import Control.Monad.Log (Severity (..))
lib/command/src/Obelisk/Command.hs+6−6
@@ -23,7 +23,7 @@ import System.Environment
23import System.FilePath
23import System.FilePath
24import qualified System.Info
24import qualified System.Info
25import System.IO (hIsTerminalDevice, stdout)
25import System.IO (hIsTerminalDevice, stdout)
26−import Text.ShellEscape (Bash, bash)
26+import Text.ShellEscape (bash, bytes)
27import System.Posix.Process (executeFile)
27import System.Posix.Process (executeFile)
28
28
29import Obelisk.App
29import Obelisk.App
@@ -400,11 +400,11 @@ ob = \case
400 ObCommand_Repl interpretPathsList -> withInterpretPaths interpretPathsList runRepl
400 ObCommand_Repl interpretPathsList -> withInterpretPaths interpretPathsList runRepl
401 ObCommand_Watch interpretPathsList -> withInterpretPaths interpretPathsList runWatch
401 ObCommand_Watch interpretPathsList -> withInterpretPaths interpretPathsList runWatch
402 ObCommand_Shell (ShellOpts shellAttr interpretPathsList cmd) -> withInterpretPaths interpretPathsList $ \root interpretPaths ->
402 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)
404 ObCommand_Doc shellAttr pkgs -> withInterpretPaths [] $ \root interpretPaths ->
404 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
406 ObCommand_Hoogle shell' port -> withProjectRoot "." $ \root -> do
406 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"
408 ObCommand_Internal icmd -> case icmd of
408 ObCommand_Internal icmd -> case icmd of
409 ObInternal_ApplyPackages origPath inPath outPath packagePaths -> do
409 ObInternal_ApplyPackages origPath inPath outPath packagePaths -> do
410 liftIO $ Preprocessor.applyPackages origPath inPath outPath packagePaths
410 liftIO $ Preprocessor.applyPackages origPath inPath outPath packagePaths
@@ -420,8 +420,8 @@ withInterpretPaths interpretPathsList f = withProjectRoot "." $ \root -> do
420 Nothing -> failWith "No paths provided for finding packages"
420 Nothing -> failWith "No paths provided for finding packages"
421 Just interpretPaths -> f root interpretPaths
421 Just interpretPaths -> f root interpretPaths
422
422
423−haddockCommand :: [String] -> Bash
423+haddockCommand :: [String] -> String
424−haddockCommand pkgs = bash $ BSU.fromString $ unwords
424+haddockCommand pkgs = unwords
425 [ "for p in"
425 [ "for p in"
426 , unwords [getHaddockPath p ++ "/index.html" | p <- pkgs]
426 , unwords [getHaddockPath p ++ "/index.html" | p <- pkgs]
427 , "; do echo $p; done"
427 , "; do echo $p; done"
lib/command/src/Obelisk/Command/Project.hs+5−5
@@ -40,7 +40,7 @@ import System.IO.Temp
40import System.IO.Unsafe (unsafePerformIO)
40import System.IO.Unsafe (unsafePerformIO)
41import System.Posix (FileStatus, FileMode, CMode (..), UserID, deviceID, fileID, fileMode, fileOwner, getFileStatus, getRealUserID)
41import System.Posix (FileStatus, FileMode, CMode (..), UserID, deviceID, fileID, fileMode, fileOwner, getFileStatus, getRealUserID)
42import System.Posix.Files
42import System.Posix.Files
43−import Text.ShellEscape (Bash, bytes, bash)
43+import Text.ShellEscape (bash, bytes)
44
44
45import GitHub.Data.GitData (Branch)
45import GitHub.Data.GitData (Branch)
46import GitHub.Data.Name (Name)
46import GitHub.Data.Name (Name)
@@ -272,7 +272,7 @@ filePermissionIsSafe s umask = not fileWorldWritable && fileGroupWritable <= uma
272 fileGroupWritable = fileMode s .&. 0o020 == 0o020
272 fileGroupWritable = fileMode s .&. 0o020 == 0o020
273 umaskGroupWritable = umask .&. 0o020 == 0
273 umaskGroupWritable = umask .&. 0o020 == 0
274
274
275−nixShellRunConfig :: MonadObelisk m => FilePath -> Bool -> Maybe [Bash] -> m NixShellConfig
275+nixShellRunConfig :: MonadObelisk m => FilePath -> Bool -> Maybe String -> m NixShellConfig
276nixShellRunConfig root isPure command = do
276nixShellRunConfig root isPure command = do
277 nixpkgsPath <- fmap T.strip $ readProcessAndLogStderr Debug $ setCwd (Just root) $
277 nixpkgsPath <- fmap T.strip $ readProcessAndLogStderr Debug $ setCwd (Just root) $
278 proc nixExePath ["eval", "(import .obelisk/impl {}).nixpkgs.path"]
278 proc nixExePath ["eval", "(import .obelisk/impl {}).nixpkgs.path"]
@@ -283,7 +283,7 @@ nixShellRunConfig root isPure command = do
283 & nixShellConfig_run .~ (command <&> \cs -> unwords $ concat
283 & nixShellConfig_run .~ (command <&> \cs -> unwords $ concat
284 [ ["export", BSU.toString . bytes . bash $ "NIX_PATH=nixpkgs=" <> encodeUtf8 nixpkgsPath, ";"]
284 [ ["export", BSU.toString . bytes . bash $ "NIX_PATH=nixpkgs=" <> encodeUtf8 nixpkgsPath, ";"]
285 , maybe [] (\v -> ["export", BSU.toString . bytes . bash $ "NIX_REMOTE=" <> encodeUtf8 (T.pack v), ";"]) nixRemote
285 , maybe [] (\v -> ["export", BSU.toString . bytes . bash $ "NIX_REMOTE=" <> encodeUtf8 (T.pack v), ";"]) nixRemote
286− , fmap (BSU.toString . bytes) cs
286+ , [cs]
287 ])
287 ])
288
288
289nixShellRunProc :: NixShellConfig -> ProcessSpec
289nixShellRunProc :: NixShellConfig -> ProcessSpec
@@ -296,7 +296,7 @@ nixShellWithoutPkgs
296 -> Bool -- ^ Should we chdir to the package root in the shell?
296 -> Bool -- ^ Should we chdir to the package root in the shell?
297 -> Map Text FilePath -- ^ Package names mapped to their paths
297 -> Map Text FilePath -- ^ Package names mapped to their paths
298 -> String -- ^ Shell attribute to use (e.g. @"ghc"@, @"ghcjs"@, etc.)
298 -> 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
300 -> m ()
300 -> m ()
301nixShellWithoutPkgs root isPure chdirToRoot packageNamesAndPaths shellAttr command = do
301nixShellWithoutPkgs root isPure chdirToRoot packageNamesAndPaths shellAttr command = do
302 packageNamesAndAbsPaths <- liftIO $ for packageNamesAndPaths makeAbsolute
302 packageNamesAndAbsPaths <- liftIO $ for packageNamesAndPaths makeAbsolute
@@ -314,7 +314,7 @@ nixShellWithoutPkgs root isPure chdirToRoot packageNamesAndPaths shellAttr comma
314 ]
314 ]
315 void $ waitForProcess ph
315 void $ waitForProcess ph
316
316
317−nixShellWithHoogle :: MonadObelisk m => FilePath -> Bool -> String -> Maybe [Bash] -> m ()
317+nixShellWithHoogle :: MonadObelisk m => FilePath -> Bool -> String -> Maybe String -> m ()
318nixShellWithHoogle root isPure shell' command = do
318nixShellWithHoogle root isPure shell' command = do
319 defShellConfig <- nixShellRunConfig root isPure command
319 defShellConfig <- nixShellRunConfig root isPure command
320 (_, _, _, ph) <- createProcess_ "nixShellWithHoogle" $ setCwd (Just root) $ nixShellRunProc $ defShellConfig
320 (_, _, _, 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)
61import System.FilePath
61import System.FilePath
62import qualified System.Info
62import qualified System.Info
63import System.IO.Temp (withSystemTempDirectory)
63import System.IO.Temp (withSystemTempDirectory)
64−import Text.ShellEscape (Bash, bash)
64+import Text.ShellEscape (bash, bytes)
65
65
66import Obelisk.App (MonadObelisk)
66import Obelisk.App (MonadObelisk)
67import Obelisk.CliApp (
67import Obelisk.CliApp (
@@ -195,7 +195,7 @@ exportGhciConfig useRelativePaths root interpretPaths = do
195 pkgs <- getParsedLocalPkgs root interpretPaths
195 pkgs <- getParsedLocalPkgs root interpretPaths
196 getGhciSessionSettings pkgs "." useRelativePaths
196 getGhciSessionSettings pkgs "." useRelativePaths
197
197
198−nixShellForInterpretPaths :: MonadObelisk m => Bool -> String -> FilePath -> PathTree Interpret -> Maybe [Bash] -> m ()
198+nixShellForInterpretPaths :: MonadObelisk m => Bool -> String -> FilePath -> PathTree Interpret -> Maybe String -> m ()
199nixShellForInterpretPaths isPure shell root interpretPaths cmd = do
199nixShellForInterpretPaths isPure shell root interpretPaths cmd = do
200 pkgs <- getParsedLocalPkgs root interpretPaths
200 pkgs <- getParsedLocalPkgs root interpretPaths
201 nixShellWithoutPkgs root isPure False (packageInfoToNamePathMap pkgs) shell cmd
201 nixShellWithoutPkgs root isPure False (packageInfoToNamePathMap pkgs) shell cmd
@@ -466,7 +466,7 @@ runGhciRepl root (toList -> packages) ghciArgs =
466 -- NOTE: We do *not* want to use $(staticWhich "ghci") here because we need the
466 -- NOTE: We do *not* want to use $(staticWhich "ghci") here because we need the
467 -- ghc that is provided by the shell in the user's project.
467 -- ghc that is provided by the shell in the user's project.
468 nixShellWithoutPkgs root True False (packageInfoToNamePathMap packages) "ghc" $
468 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
470
470
471-- | Run ghcid
471-- | Run ghcid
472runGhcid
472runGhcid
@@ -479,7 +479,7 @@ runGhcid
479 -> m ()
479 -> m ()
480runGhcid root chdirToRoot ghciArgs (toList -> packages) mcmd =
480runGhcid root chdirToRoot ghciArgs (toList -> packages) mcmd =
481 nixShellWithoutPkgs root True chdirToRoot (packageInfoToNamePathMap packages) "ghc" $
481 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
483 where
483 where
484 opts = concat
484 opts = concat
485 [ ["-W"]
485 [ ["-W"]