License | GPL-2 |
---|---|
Maintainer | [email protected] |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Extensions |
|
Yi.Option
Description
Command-line options
- type YiOption = Config -> Either OptionError Config
- type YiOptionDescr = OptDescr YiOption
- data YiOptions
- data OptionError = OptionError Text ExitCode
- yiCustomOptions :: Lens' Config [YiOptionDescr]
- consYiOption :: YiOptionDescr -> Config -> Config
- consYiOptions :: [YiOptionDescr] -> Config -> Config
- yiBoolOption :: Lens' Config Bool -> ArgDescr YiOption
- yiFlagOption :: Lens' Config a -> (a -> a) -> ArgDescr YiOption
- yiActionFlagOption :: Action -> ArgDescr YiOption
- yiStringOption :: IsString a => Lens' Config a -> String -> ArgDescr YiOption
- yiStringOption' :: IsString a => Lens' Config (Maybe a) -> String -> ArgDescr YiOption
- yiActionOption :: IsString a => (a -> Action) -> String -> ArgDescr YiOption
- yiActionOption' :: IsString a => (a -> Either OptionError Action) -> String -> ArgDescr YiOption
Types
type YiOption = Config -> Either OptionError Config Source #
An option is a function that attempts to change the configuration of the editor at runtime.
type YiOptionDescr = OptDescr YiOption Source #
Custom options that should be accepted. Provided in user configuration.
The general flow is that the user adds options to his configuration. Options are essentially functions describing how to modify the configuration at runtime. When an option is called, it gets the current config and may modify it (to encode its value)
data OptionError Source #
Constructors
OptionError Text ExitCode |
Core
yiCustomOptions :: Lens' Config [YiOptionDescr] Source #
Lens for accessing the list of custom options.
You can pretty much create whatever types of options you want with this. But most cases are taken care of by one of the helper functions in this module.
consYiOption :: YiOptionDescr -> Config -> Config Source #
Includes an extra option in the configuration. Small wrapper around yiCustomOptions
consYiOptions :: [YiOptionDescr] -> Config -> Config Source #
Like consYiOption
but supports multiple options. Convenient for keymaps which might
want to install lots of options.
Argument-less options
yiBoolOption :: Lens' Config Bool -> ArgDescr YiOption Source #
An argument which sets some configuration value to True
.
yiFlagOption :: Lens' Config a -> (a -> a) -> ArgDescr YiOption Source #
An argument which applies a function transforming some inner value of the configuration.
yiActionFlagOption :: Action -> ArgDescr YiOption Source #
Flag that appends an action to the startup actions.
Argument-taking options
yiStringOption :: IsString a => Lens' Config a -> String -> ArgDescr YiOption Source #
Sets the value of an option which is any string type (hopefully text...)
This is not meant to be fully applied. By only passing in the lens you will obtain a value suitable for use in OptDescr.
yiStringOption' :: IsString a => Lens' Config (Maybe a) -> String -> ArgDescr YiOption Source #
Just like yiStringOption
, except it applies a Just
. Useful for setting
string-like values whose default is None
.
yiActionOption :: IsString a => (a -> Action) -> String -> ArgDescr YiOption Source #
Option that appends a parameterized action to the startup actions.
yiActionOption' :: IsString a => (a -> Either OptionError Action) -> String -> ArgDescr YiOption Source #