stackage-cli- A CLI library for stackage commands

Safe HaskellNone




Functions for creating and calling Stackage plugins.


Discovering and calling plugins

runStackagePlugin :: Text -> [String] -> IO () Source

Runs a stackage plugin. Handy for dynamic one-off runs, but if you'll be running multiple plugins, it is recommended that you use findPlugins "stackage" so that the plugin search is performed only once.

data Plugins Source

Represents the plugins available to a given program. See: findPlugins.


findPlugins :: Text -> IO Plugins Source

Find the plugins for a given program by inspecting everything on the PATH. Any program that is prefixed with the given name and responds to the `--summary` flag by writing one line to stdout is considered a plugin.

callPlugin :: (MonadIO m, MonadThrow m) => Plugins -> Text -> [String] -> m () Source

A convenience wrapper around lookupPlugin and pluginProc. Handles stdin, stdout, and stderr are all inherited by the plugin. Throws PluginException.

Creating your own plugin

commandsFromPlugins :: Plugins -> EitherT Text (Writer (Mod CommandFields Text)) () Source

Generate the "commands" argument to simpleOptions based on available plugins.

simpleOptions Source


:: String

version string

-> String


-> String

program description

-> Parser a

global settings

-> EitherT b (Writer (Mod CommandFields b)) ()

commands (use addCommand)

-> IO (a, b) 

This is a drop-in replacement for simpleOptions from Options.Applicative.Simple, with the added feature of a `--summary` flag that prints out the header. (Should be one line)



:: String

command string

-> String

title of command

-> (a -> b)

constructor to wrap up command in common data type

-> Parser a

command parser

-> EitherT b (Writer (Mod CommandFields b)) () 

Add a command to the options dispatcher.

simpleVersion :: Version -> Q Exp

Generate a string like Version 1.2, Git revision 1234.

$(simpleVersion …) :: String

Finer-grained inspection of plugins

listPlugins :: Plugins -> [Plugin] Source

List the available plugins.

lookupPlugin :: Plugins -> Text -> Maybe Plugin Source

Look up a particular plugin by name.

data Plugin Source

Represents a runnable plugin. Plugins must be discovered via findPlugins.


pluginPrefix :: Plugin -> Text Source

The program being plugged into.

pluginName :: Plugin -> Text Source

The name of this plugin (without the prefix).

pluginSummary :: Plugin -> Text Source

A summary of what this plugin does

pluginProc :: Plugin -> [String] -> CreateProcess Source

Describes how to create a process out of a plugin and arguments. You may use Data.Process and Data.Conduit.Process to manage the process's stdin, stdout, and stderr in various ways.