X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/fad06963e37b4871e051a27a5908cec2ea00d1b1..04edfc993eadb9b069dfef83c3fa3a7ff31ae0d9:/htools/Ganeti/Common.hs?ds=sidebyside diff --git a/htools/Ganeti/Common.hs b/htools/Ganeti/Common.hs index 1485a91..4e5a275 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 @@ -183,10 +184,11 @@ parseOpts :: (StandardOptions a) => -> [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 -parseOpts defaults argv progname options = - case parseOptsInner defaults argv progname options of +parseOpts defaults argv progname options arguments = + case parseOptsInner defaults argv progname options arguments of Left (code, msg) -> do hPutStr (if code == ExitSuccess then stdout else stderr) msg exitWith code @@ -201,8 +203,9 @@ parseOptsInner :: (StandardOptions a) => -> [String] -> String -> [GenericOptType a] + -> [ArgCompletion] -> Either (ExitCode, String) (a, [String]) -parseOptsInner defaults argv progname options = +parseOptsInner defaults argv progname options arguments = case getOpt Permute (map fst options) argv of (opts, args, []) -> case foldM (flip id) defaults opts of @@ -216,7 +219,8 @@ parseOptsInner defaults argv progname options = , (verRequested parsed, Left (ExitSuccess, versionInfo progname)) , (compRequested parsed, - Left (ExitSuccess, completionInfo progname options [])) + Left (ExitSuccess, completionInfo progname options + arguments)) ] (_, _, errs) -> Left (ExitFailure 2, "Command line error: " ++ concat errs ++ "\n" ++