on master help sign in
Merge branch 'develop' into eac@fix-custom-prelude-ob-profile
commite622515546bf8f91ef1ec4a86877daea265a2dbf authorElliot Cameron <3noch@users.noreply.github.com> dateTue 19 May 2020, 20:32 (6 years ago) parent72ba33e37d3550
2 files changed+11−3
lib/command/src/Obelisk/Command.hs+5−2 lib/selftest/src/Obelisk/SelfTest.hs+6−1
lib/command/src/Obelisk/Command.hs+5−2
@@ -114,7 +114,7 @@ obCommand cfg = hsubparser
114114 , command "thunk" $ info (ObCommand_Thunk <$> thunkOption) $ progDesc "Manipulate thunk directories"
115115 , command "repl" $ info (ObCommand_Repl <$> interpretOpts) $ progDesc "Open an interactive interpreter"
116116 , command "watch" $ info (ObCommand_Watch <$> interpretOpts) $ progDesc "Watch current project for errors and warnings"
117− , command "shell" $ info (ObCommand_Shell <$> shellOpts) $ progDesc "Enter a shell with project dependencies"
117+ , command "shell" $ info (ObCommand_Shell <$> shellOpts) $ progDesc "Enter a shell with project dependencies or run a command in such a shell. E.g. ob shell -- ghc-pkg list"
118118 , command "doc" $ info (ObCommand_Doc <$> shellFlags <*> packageNames) $
119119 progDesc "List paths to haddock documentation for specified packages"
120120 <> footerDoc (Just $
@@ -285,7 +285,10 @@ shellOpts :: Parser ShellOpts
285285shellOpts = ShellOpts
286286 <$> shellFlags
287287 <*> interpretOpts
288− <*> optional (strArgument (metavar "COMMAND"))
288+ -- This funny construction is used to support optparse-applicative's @--@ parsing.
289+ -- All arguments after @--@ are left unparsed and instead provided to the last positional parser
290+ -- which must therefore be 'many' in order to consume the rest of the input.
291+ <*> ((\xs -> if null xs then Nothing else Just $ unwords xs) <$> many (strArgument (metavar "COMMAND")))
289292
290293portOpt :: Int -> Parser Int
291294portOpt dfault = option auto (long "port" <> short 'p' <> help "Port number for server" <> showDefault <> value dfault <> metavar "INT")
lib/selftest/src/Obelisk/SelfTest.hs+6−1
@@ -243,7 +243,7 @@ main' isVerbose httpManager obeliskRepoReadOnly = withInitCache $ \initCache ->
243243 uu <- update
244244 assertRevEQ u uu
245245
246− it "can run 'ob doc'" $ inTmpObInit $ \_ -> runOb ["doc", "reflex"]
246+ it "can run 'ob doc'" $ inTmpObInit $ \_ -> runOb_ ["doc", "reflex"]
247247
248248 describe "ob thunk pack/unpack" $ parallel $ do
249249 it "has thunk pack and unpack inverses" $ inTmpObInitWithImplCopy $ \_ -> do
@@ -306,6 +306,11 @@ main' isVerbose httpManager obeliskRepoReadOnly = withInitCache $ \initCache ->
306306 void $ errExit False $ runOb ["thunk", "update", toTextIgnore dir, "--branch", "dumble-palooza"]
307307 checkDir dir >>= liftIO . assertEqual "" startingContents
308308
309+ describe "ob shell" $ parallel $ do
310+ it "works with --" $ inTmpObInit $ \_ -> do
311+ output <- runOb ["shell", "--", "ghc-pkg", "list"]
312+ liftIO $ assertBool "Unexpected output from ob shell" $ ("Cabal-" `T.isInfixOf` output) && ("ghc-" `T.isInfixOf` output)
313+
309314 describe "ob hoogle" $ {- NOT parallel -} do
310315 it "starts a hoogle server on the given port" $ inTmpObInit $ \_ -> do
311316 [p0] <- liftIO $ getFreePorts 1