ganeti

Safe HaskellNone

Ganeti.Common

Description

Base common functionality.

This module holds common functionality shared across Ganeti daemons, HTools and any other programs.

Synopsis

Documentation

data OptCompletion Source #

Parameter type.

Constructors

OptComplNone

No parameter to this option

OptComplFile

An existing file

OptComplDir

An existing directory

OptComplHost

Host name

OptComplInetAddr

One ipv4/ipv6 address

OptComplOneNode

One node

OptComplManyNodes

Many nodes, comma-sep

OptComplOneInstance

One instance

OptComplManyInstances

Many instances, comma-sep

OptComplOneOs

One OS name

OptComplOneIallocator

One iallocator

OptComplInstAddNodes

Either one or two nodes

OptComplOneGroup

One group

OptComplInteger

Integer values

OptComplFloat

Float values

OptComplJobId

Job Id

OptComplCommand

Command (executable)

OptComplString

Arbitrary string

OptComplChoices [String]

List of string choices

OptComplSuggest [String]

Suggested choices

Instances
Eq OptCompletion # 
Instance details

Defined in Ganeti.Common

Show OptCompletion # 
Instance details

Defined in Ganeti.Common

Methods

showsPrec :: Int -> OptCompletion -> ShowS

show :: OptCompletion -> String

showList :: [OptCompletion] -> ShowS

data ArgCompletion Source #

Argument type. This differs from (and wraps) an Option by the fact that it can (and usually does) support multiple repetitions of the same argument, via a min and max limit.

Constructors

ArgCompletion OptCompletion Int (Maybe Int) 
Instances
Eq ArgCompletion # 
Instance details

Defined in Ganeti.Common

Show ArgCompletion # 
Instance details

Defined in Ganeti.Common

Methods

showsPrec :: Int -> ArgCompletion -> ShowS

show :: ArgCompletion -> String

showList :: [ArgCompletion] -> ShowS

type PersonalityList a = [(String, Personality a)] Source #

Personality lists type, common across all binaries that expose multiple personalities.

optComplYesNo :: OptCompletion Source #

Yes/no choices completion.

type GenericOptType a = (OptDescr (a -> Result a), OptCompletion) Source #

Abbreviation for the option type.

oShowHelp :: StandardOptions a => GenericOptType a Source #

Option to request help output.

oShowVer :: StandardOptions a => GenericOptType a Source #

Option to request version information.

oShowComp :: StandardOptions a => GenericOptType a Source #

Option to request completion information

usageHelp :: String -> [GenericOptType a] -> String Source #

Usage info.

versionInfo :: String -> String Source #

Show the program version info.

parseYesNo Source #

Arguments

:: Bool

Default value (when we get a Nothing)

-> Maybe String

Parameter value

-> Result Bool

Resulting boolean value

Helper for parsing a yes/no command line flag.

reqWithConversion :: (String -> Result a) -> (a -> b -> Result b) -> String -> ArgDescr (b -> Result b) Source #

Helper function for required arguments which need to be converted as opposed to stored just as string.

formatCommands :: StandardOptions a => PersonalityList a -> [String] Source #

Formats the description of various commands.

parseOpts Source #

Arguments

:: StandardOptions a 
=> a

The default options

-> [String]

The command line arguments

-> String

The program name

-> [GenericOptType a]

The supported command line options

-> [ArgCompletion]

The supported command line arguments

-> IO (a, [String])

The resulting options and leftover arguments

Command line parser, using a generic Options structure.

parseOptsCmds Source #

Arguments

:: StandardOptions a 
=> a

The default options

-> [String]

The command line arguments

-> String

The program name

-> PersonalityList a

The supported commands

-> [GenericOptType a]

Generic options

-> IO (a, [String], a -> [String] -> IO ())

The resulting options and leftover arguments

Command line parser, for programs with sub-commands.

parseOptsInner :: StandardOptions a => a -> [String] -> String -> [GenericOptType a] -> [ArgCompletion] -> Either (ExitCode, String) (a, [String]) Source #

Inner parse options. The arguments are similar to parseOpts, but it returns either a Left composed of exit code and message, or a Right for the success case.

genericMainCmds :: StandardOptions a => a -> PersonalityList a -> [GenericOptType a] -> IO () Source #

Parse command line options and execute the main function of a multi-personality binary.

fillUpList :: ([(a, b)] -> a -> (a, b)) -> [a] -> [(a, b)] -> [(a, b)] Source #

Order a list of pairs in the order of the given list and fill up the list for elements that don't have a matching pair

fillPairFromMaybe :: (a -> (a, b)) -> (a -> [(a, b)] -> Maybe (a, b)) -> [(a, b)] -> a -> (a, b) Source #

Fill up a pair with fillup element if no matching pair is present

pickPairUnique :: Eq a => a -> [(a, b)] -> Maybe (a, b) Source #

Pick a specific element's pair from the list