Skip to content
Snippets Groups Projects
Commit f5af3409 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add a data type for completion information


This can be used for either option or argument completion (although
OptComplNone doesn't make sense for an argument :).

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
parent 42834645
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
module Ganeti.Common
( GenericOptType
, StandardOptions(..)
, OptCompletion(..)
, optComplYesNo
, oShowHelp
, oShowVer
, usageHelp
......@@ -50,6 +52,29 @@ import Text.Printf (printf)
import Ganeti.BasicTypes
import qualified Ganeti.Version as Version (version)
-- | Parameter type.
data OptCompletion = 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
| OptComplNumeric -- ^ Float values
| OptComplString -- ^ Arbitrary string
| OptComplChoices [String] -- ^ List of string choices
deriving (Show, Read, Eq)
-- | Yes\/no choices completion.
optComplYesNo :: OptCompletion
optComplYesNo = OptComplChoices ["yes", "no"]
-- | Abrreviation for the option type.
type GenericOptType a = OptDescr (a -> Result a)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment