-
-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
Iris.need is the main function for checking whether a specified tool executable in PATH:
need :: MonadIO m => [Tool] -> m ()It supposed to be used like this in the main application code:
app :: App ()
app = Iris.asksCliEnv Iris.cliEnvCmd >>= \case
Download url -> do
need ["curl"]
runDownload url
Evaluate hs -> do
need ["ghc", "cabal"]
runEvaluate hsWhere the Tool type is the following:
Lines 43 to 71 in c1597ee
| data Tool = Tool | |
| { toolName :: Text | |
| -- ^ @since 0.0.0.0 | |
| , toolSelector :: Maybe ToolSelector | |
| -- ^ @since 0.0.0.0 | |
| } | |
| {- | | |
| @since 0.0.0.0 | |
| -} | |
| instance IsString Tool where | |
| fromString :: String -> Tool | |
| fromString s = | |
| Tool | |
| { toolName = fromString s | |
| , toolSelector = Nothing | |
| } | |
| {- | | |
| @since 0.0.0.0 | |
| -} | |
| data ToolSelector = ToolSelector | |
| { toolSelectorFunction :: Text -> Bool | |
| -- ^ @since 0.0.0.0 | |
| , toolSelectorVersionArg :: Maybe Text | |
| -- ^ @since 0.0.0.0 | |
| } |
It does the job but it's a bit suboptimal and maybe inconvenient at times.
I'd love to improve this API in the following way:
- Provide eDSL for specifying the minimum required version
- Provide eDSL for specifying the flag for checking the version
With such an eDSL, it should be possible to write the following code:
ghc :: Iris.Tool
ghc = "ghc" `Iris.versionAtLeast` [8, 10, 7] `Iris.usingVersionFlag` "--numeric-version"
cabal :: Iris.Tool
cabal = "cabal" `Iris.versionAtLeast` [3, 6, 2, 0] `Iris.usingVersionFlag` "--numeric-version"
app :: App ()
app = Iris.asksCliEnv Iris.cliEnvCmd >>= \case
Download url -> do
need ["curl"]
runDownload url
Evaluate hs -> do
need [ghc, cabal]
runEvaluate hsThe checkToolFunction should patched accordingly.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers