@@ -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
@@ -99,34 +97,28 @@ data ObCommand
9997 deriving Show
10098
10199data ObInternal
102− = ObInternal_RunStaticIO StaticKey
103100 -- the preprocessor argument syntax is also handled outside
104101 -- optparse-applicative, but it shouldn't ever conflict with another syntax
105− | ObInternal_ApplyPackages String String String [String]
102+ = ObInternal_ApplyPackages String String String [String]
106103 deriving Show
107104
108105obCommand :: ArgsConfig -> Parser ObCommand
109106obCommand cfg = hsubparser
110− (mconcat
111− [ command "init" $ info (ObCommand_Init <$> initSource <*> initForce) $ progDesc "Initialize an Obelisk project"
112− , command "deploy" $ info (ObCommand_Deploy <$> deployCommand cfg) $ progDesc "Prepare a deployment for an Obelisk project"
113− , command "run" $ info (pure ObCommand_Run) $ progDesc "Run current project in development mode"
114− , command "thunk" $ info (ObCommand_Thunk <$> thunkCommand) $ progDesc "Manipulate thunk directories"
115− , command "repl" $ info (pure ObCommand_Repl) $ progDesc "Open an interactive interpreter"
116− , command "watch" $ info (pure ObCommand_Watch) $ progDesc "Watch current project for errors and warnings"
117− , command "shell" $ info (ObCommand_Shell <$> shellOpts) $ progDesc "Enter a shell with project dependencies"
118− , command "doc" $ info (ObCommand_Doc <$> shellFlags <*> packageNames) $
119− progDesc "List paths to haddock documentation for specified packages"
120− <> footerDoc (Just $
121− text "Hint: To open the documentation you can pipe the output of this command like"
122− <$$> text "ob doc reflex reflex-dom-core | xargs -n1 xdg-open")
123− , command "hoogle" $ info (ObCommand_Hoogle <$> shellFlags <*> portOpt 8080) $ progDesc "Run a hoogle server locally for your project's dependency tree"
124− ])
125− <|> subparser
126− (mconcat
127− [ internal
128− , command "internal" (info (ObCommand_Internal <$> internalCommand) mempty)
129− ])
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+ ])
130122
131123packageNames :: Parser [String]
132124packageNames = some (strArgument (metavar "PACKAGE-NAME..."))
@@ -191,11 +183,6 @@ data DeployInitOpts = DeployInitOpts
191183 }
192184 deriving Show
193185
194−internalCommand :: Parser ObInternal
195−internalCommand = subparser $ mconcat
196− [ command "run-static-io" $ info (ObInternal_RunStaticIO <$> argument (eitherReader decodeStaticKey) (action "static-key")) mempty
197− ]
198−
199186--TODO: Result should provide normalised path and also original user input for error reporting.
200187thunkDirectoryParser :: Parser FilePath
201188thunkDirectoryParser = fmap (dropTrailingPathSeparator . normalise) . strArgument $ mconcat
@@ -392,11 +379,6 @@ ob = \case
392379 ObCommand_Hoogle shell' port -> withProjectRoot "." $ \root -> do
393380 nixShellWithHoogle root True shell' $ Just $ "hoogle server -p " <> show port <> " --local"
394381 ObCommand_Internal icmd -> case icmd of
395− ObInternal_RunStaticIO k -> liftIO (unsafeLookupStaticPtr @(ObeliskT IO ()) k) >>= \case -- TODO: DELETE
396− Nothing -> failWith $ "ObInternal_RunStaticIO: no such StaticKey: " <> T.pack (show k)
397− Just p -> do
398− c <- getObelisk
399− liftIO $ runObelisk c $ deRefStaticPtr p
400382 ObInternal_ApplyPackages origPath inPath outPath packagePaths -> do
401383 liftIO $ Preprocessor.applyPackages origPath inPath outPath packagePaths
402384