darcs-2.18.2: a distributed, interactive, smart revision control system

Safe Haskell | None
Language | Haskell2010

Darcs.UI.Defaults

Synopsis

- applyDefaults :: Maybe String -> DarcsCommand -> AbsolutePath -> [String] -> [String] -> [DarcsFlag] -> ([DarcsFlag], ([String], [String]))

# Documentation

applyDefaults #

Arguments

:: Maybe String | maybe name of super command
-> DarcsCommand | the darcs command
-> AbsolutePath | the original working directory, i.e. the one from which darcs was invoked
-> [String] | lines from user defaults
-> [String] | lines from repo defaults
-> [DarcsFlag] | flags from command line
-> ([DarcsFlag], ([String], [String])) |

Apply defaults from all sources to a list of `DarcsFlag`s (e.g. from the command line), given the command (and possibly super command) name, and a list of all options for the command.

Sources for defaults are

- the builtin (hard-coded) defaults,
- the defaults file in the user's configuration, and
- the defaults file in the current repository.

Note that the pseudo command `ALL` is allowed in defaults files to specify that an option should be the default for all commands to which it applies.

The order of precedence for conflicting options (i.e. those belonging to same group of mutually exclusive options) is from less specific to more specific. In other words, options from the command line override all defaults, per-repo defaults override per-user defaults, which in turn override the built-in defaults. Inside the options from a defaults file, options for the given command override options for the `ALL` pseudo command.

Conflicting options at the same level of precedence are not allowed.

Errors encountered during processing of command line or defaults flags are formatted and added as (separate) strings to the list of error messages that are returned together with the resulting flag list.