From f5af3409b73a4cfbba30c6139d8a92cf1951175e Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 25 Sep 2012 11:30:29 +0200
Subject: [PATCH] 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: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>
---
 htools/Ganeti/Common.hs | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/htools/Ganeti/Common.hs b/htools/Ganeti/Common.hs
index 43caf278b..379e63f1d 100644
--- a/htools/Ganeti/Common.hs
+++ b/htools/Ganeti/Common.hs
@@ -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)
 
-- 
GitLab