From ecebe9f60d384ef5e09ad3b74c97e0079dd4784a Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Fri, 5 Oct 2012 22:23:09 +0200
Subject: [PATCH] Split the OptComplNumeric into integer/float ones

This allows the command completion to treat them as separate option
types; this is not useful in build-bash-completion right now, but
might become so in the future.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 autotools/build-bash-completion |  7 ++++---
 htools/Ganeti/Common.hs         |  3 ++-
 htools/Ganeti/Daemon.hs         |  2 +-
 htools/Ganeti/HTools/CLI.hs     | 14 +++++++-------
 4 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/autotools/build-bash-completion b/autotools/build-bash-completion
index 0dd77b02d..058ae7705 100755
--- a/autotools/build-bash-completion
+++ b/autotools/build-bash-completion
@@ -644,9 +644,10 @@ def HaskellOptToOptParse(opts, kind):
     return cli.cli_option(*opts, action="store_true")
   elif kind in ["file", "string", "host", "dir", "inetaddr"]:
     return cli.cli_option(*opts, type="string")
-  elif kind == "numeric":
-    # FIXME: float values here
-    return cli.cli_option(*opts, type="string")
+  elif kind == "integer":
+    return cli.cli_option(*opts, type="int")
+  elif kind == "float":
+    return cli.cli_option(*opts, type="float")
   elif kind == "onegroup":
     return cli.cli_option(*opts, type="string",
                            completion_suggest=cli.OPT_COMPL_ONE_NODEGROUP)
diff --git a/htools/Ganeti/Common.hs b/htools/Ganeti/Common.hs
index 94e256ddb..4e5a275e7 100644
--- a/htools/Ganeti/Common.hs
+++ b/htools/Ganeti/Common.hs
@@ -71,7 +71,8 @@ data OptCompletion = OptComplNone             -- ^ No parameter to this option
                    | OptComplOneIallocator    -- ^ One iallocator
                    | OptComplInstAddNodes     -- ^ Either one or two nodes
                    | OptComplOneGroup         -- ^ One group
-                   | OptComplNumeric          -- ^ Float values
+                   | OptComplInteger          -- ^ Integer values
+                   | OptComplFloat            -- ^ Float values
                    | OptComplJobId            -- ^ Job Id
                    | OptComplCommand          -- ^ Command (executable)
                    | OptComplString           -- ^ Arbitrary string
diff --git a/htools/Ganeti/Daemon.hs b/htools/Ganeti/Daemon.hs
index 43187ed9f..94676ad15 100644
--- a/htools/Ganeti/Daemon.hs
+++ b/htools/Ganeti/Daemon.hs
@@ -144,7 +144,7 @@ oPort def =
    (reqWithConversion (tryRead "reading port")
     (\port opts -> Ok opts { optPort = Just port }) "PORT")
    ("Network port (default: " ++ show def ++ ")"),
-   OptComplNumeric)
+   OptComplInteger)
 
 oBindAddress :: OptType
 oBindAddress =
diff --git a/htools/Ganeti/HTools/CLI.hs b/htools/Ganeti/HTools/CLI.hs
index 542a5847b..69e08064b 100644
--- a/htools/Ganeti/HTools/CLI.hs
+++ b/htools/Ganeti/HTools/CLI.hs
@@ -256,7 +256,7 @@ oSpindleUse =
        return $ opts { optSpindleUse = Just su })
     "SPINDLES") "select how many virtual spindle instances use\
                 \ [default read from cluster]",
-   OptComplNumeric)
+   OptComplFloat)
 
 oSelInst :: OptType
 oSelInst =
@@ -354,7 +354,7 @@ oMaxCpu =
        return $ opts { optMcpu = Just mcpu }) "RATIO")
    "maximum virtual-to-physical cpu ratio for nodes (from 0\
    \ upwards) [default read from cluster]",
-   OptComplNumeric)
+   OptComplFloat)
 
 oMaxSolLength :: OptType
 oMaxSolLength =
@@ -364,7 +364,7 @@ oMaxSolLength =
    "cap the solution at this many balancing or allocation \
    \ rounds (useful for very unbalanced clusters or empty \
    \ clusters)",
-   OptComplNumeric)
+   OptComplInteger)
 
 oMinDisk :: OptType
 oMinDisk =
@@ -372,7 +372,7 @@ oMinDisk =
    (reqWithConversion (tryRead "min free disk space")
     (\n opts -> Ok opts { optMdsk = n }) "RATIO")
    "minimum free disk space for nodes (between 0 and 1) [0]",
-   OptComplNumeric)
+   OptComplFloat)
 
 oMinGain :: OptType
 oMinGain =
@@ -380,7 +380,7 @@ oMinGain =
    (reqWithConversion (tryRead "min gain")
     (\g opts -> Ok opts { optMinGain = g }) "DELTA")
    "minimum gain to aim for in a balancing step before giving up",
-   OptComplNumeric)
+   OptComplFloat)
 
 oMinGainLim :: OptType
 oMinGainLim =
@@ -388,7 +388,7 @@ oMinGainLim =
    (reqWithConversion (tryRead "min gain limit")
     (\g opts -> Ok opts { optMinGainLim = g }) "SCORE")
    "minimum cluster score for which we start checking the min-gain",
-   OptComplNumeric)
+   OptComplFloat)
 
 oMinScore :: OptType
 oMinScore =
@@ -396,7 +396,7 @@ oMinScore =
    (reqWithConversion (tryRead "min score")
     (\e opts -> Ok opts { optMinScore = e }) "EPSILON")
    "mininum score to aim for",
-   OptComplNumeric)
+   OptComplFloat)
 
 oNoHeaders :: OptType
 oNoHeaders =
-- 
GitLab