ganeti

Safe HaskellSafe-Infered

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

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

type Personality a = (a -> [String] -> IO (), IO [GenericOptType a], [ArgCompletion], String)Source

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

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

optComplYesNo :: OptCompletionSource

Yes/no choices completion.

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

Abbreviation for the option type.

class StandardOptions a whereSource

Type class for options which support help and version.

Methods

helpRequested :: a -> BoolSource

verRequested :: a -> BoolSource

compRequested :: a -> BoolSource

requestHelp :: a -> aSource

requestVer :: a -> aSource

requestComp :: a -> aSource

oShowHelp :: StandardOptions a => GenericOptType aSource

Option to request help output.

oShowVer :: StandardOptions a => GenericOptType aSource

Option to request version information.

oShowComp :: StandardOptions a => GenericOptType aSource

Option to request completion information

usageHelp :: String -> [GenericOptType a] -> StringSource

Usage info.

versionInfo :: String -> StringSource

Show the program version info.

completionInfo :: String -> [GenericOptType a] -> [ArgCompletion] -> StringSource

parseYesNoSource

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.

showCmdUsage :: StandardOptions a => String -> PersonalityList a -> Bool -> IO bSource

parseOptsSource

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.

parseOptsCmdsSource

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

isMatchingPair :: Eq a => a -> (a, b) -> BoolSource

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

Pick a specific element's pair from the list