@@ -3,8 +3,6 @@
33{-# LANGUAGE MultiParamTypeClasses #-}
44{-# LANGUAGE OverloadedStrings #-}
55{-# LANGUAGE ScopedTypeVariables #-}
6−{-# LANGUAGE StaticPointers #-}
7−{-# LANGUAGE TypeApplications #-}
86module Obelisk.Command where
97
108import Control.Monad
@@ -30,7 +28,6 @@ import System.Posix.Process (executeFile)
3028
3129import Obelisk.App
3230import Obelisk.CliApp
33−import Obelisk.CliApp.Demo (cliDemo)
3431import Obelisk.Command.Deploy
3532import Obelisk.Command.Project
3633import Obelisk.Command.Run
@@ -100,35 +97,28 @@ data ObCommand
10097 deriving Show
10198
10299data ObInternal
103− = ObInternal_RunStaticIO StaticKey
104− | ObInternal_CLIDemo
105100 -- the preprocessor argument syntax is also handled outside
106101 -- optparse-applicative, but it shouldn't ever conflict with another syntax
107− | ObInternal_ApplyPackages String String String [String]
102+ = ObInternal_ApplyPackages String String String [String]
108103 deriving Show
109104
110105obCommand :: ArgsConfig -> Parser ObCommand
111106obCommand cfg = hsubparser
112− (mconcat
113− [ command "init" $ info (ObCommand_Init <$> initSource <*> initForce) $ progDesc "Initialize an Obelisk project"
114− , command "deploy" $ info (ObCommand_Deploy <$> deployCommand cfg) $ progDesc "Prepare a deployment for an Obelisk project"
115− , command "run" $ info (pure ObCommand_Run) $ progDesc "Run current project in development mode"
116− , command "thunk" $ info (ObCommand_Thunk <$> thunkCommand) $ progDesc "Manipulate thunk directories"
117− , command "repl" $ info (pure ObCommand_Repl) $ progDesc "Open an interactive interpreter"
118− , command "watch" $ info (pure ObCommand_Watch) $ progDesc "Watch current project for errors and warnings"
119− , command "shell" $ info (ObCommand_Shell <$> shellOpts) $ progDesc "Enter a shell with project dependencies"
120− , command "doc" $ info (ObCommand_Doc <$> shellFlags <*> packageNames) $
121− progDesc "List paths to haddock documentation for specified packages"
122− <> footerDoc (Just $
123− text "Hint: To open the documentation you can pipe the output of this command like"
124− <$$> text "ob doc reflex reflex-dom-core | xargs -n1 xdg-open")
125− , command "hoogle" $ info (ObCommand_Hoogle <$> shellFlags <*> portOpt 8080) $ progDesc "Run a hoogle server locally for your project's dependency tree"
126− ])
127− <|> subparser
128− (mconcat
129− [ internal
130− , command "internal" (info (ObCommand_Internal <$> internalCommand) mempty)
131− ])
107+ (mconcat
108+ [ command "init" $ info (ObCommand_Init <$> initSource <*> initForce) $ progDesc "Initialize an Obelisk project"
109+ , command "deploy" $ info (ObCommand_Deploy <$> deployCommand cfg) $ progDesc "Prepare a deployment for an Obelisk project"
110+ , command "run" $ info (pure ObCommand_Run) $ progDesc "Run current project in development mode"
111+ , command "thunk" $ info (ObCommand_Thunk <$> thunkCommand) $ progDesc "Manipulate thunk directories"
112+ , command "repl" $ info (pure ObCommand_Repl) $ progDesc "Open an interactive interpreter"
113+ , command "watch" $ info (pure ObCommand_Watch) $ progDesc "Watch current project for errors and warnings"
114+ , command "shell" $ info (ObCommand_Shell <$> shellOpts) $ progDesc "Enter a shell with project dependencies"
115+ , command "doc" $ info (ObCommand_Doc <$> shellFlags <*> packageNames) $
116+ progDesc "List paths to haddock documentation for specified packages"
117+ <> footerDoc (Just $
118+ text "Hint: To open the documentation you can pipe the output of this command like"
119+ <$$> text "ob doc reflex reflex-dom-core | xargs -n1 xdg-open")
120+ , command "hoogle" $ info (ObCommand_Hoogle <$> shellFlags <*> portOpt 8080) $ progDesc "Run a hoogle server locally for your project's dependency tree"
121+ ])
132122
133123packageNames :: Parser [String]
134124packageNames = some (strArgument (metavar "PACKAGE-NAME..."))
@@ -193,12 +183,6 @@ data DeployInitOpts = DeployInitOpts
193183 }
194184 deriving Show
195185
196−internalCommand :: Parser ObInternal
197−internalCommand = subparser $ mconcat
198− [ command "run-static-io" $ info (ObInternal_RunStaticIO <$> argument (eitherReader decodeStaticKey) (action "static-key")) mempty
199− , command "clidemo" $ info (pure ObInternal_CLIDemo) mempty
200− ]
201−
202186--TODO: Result should provide normalised path and also original user input for error reporting.
203187thunkDirectoryParser :: Parser FilePath
204188thunkDirectoryParser = fmap (dropTrailingPathSeparator . normalise) . strArgument $ mconcat
@@ -395,12 +379,6 @@ ob = \case
395379 ObCommand_Hoogle shell' port -> withProjectRoot "." $ \root -> do
396380 nixShellWithHoogle root True shell' $ Just $ "hoogle server -p " <> show port <> " --local"
397381 ObCommand_Internal icmd -> case icmd of
398− ObInternal_RunStaticIO k -> liftIO (unsafeLookupStaticPtr @(ObeliskT IO ()) k) >>= \case -- TODO: DELETE
399− Nothing -> failWith $ "ObInternal_RunStaticIO: no such StaticKey: " <> T.pack (show k)
400− Just p -> do
401− c <- getObelisk
402− liftIO $ runObelisk c $ deRefStaticPtr p
403− ObInternal_CLIDemo -> cliDemo -- TODO: DELETE
404382 ObInternal_ApplyPackages origPath inPath outPath packagePaths -> do
405383 liftIO $ Preprocessor.applyPackages origPath inPath outPath packagePaths
406384