X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/262a08a2d2cd645032016de106af6eb9c20849d9..0991ed70029a3a3d14f888c5c6d5d0772a6bdb5f:/Ganeti/HTools/CLI.hs?ds=sidebyside diff --git a/Ganeti/HTools/CLI.hs b/Ganeti/HTools/CLI.hs index fea6037..6de77ee 100644 --- a/Ganeti/HTools/CLI.hs +++ b/Ganeti/HTools/CLI.hs @@ -33,18 +33,26 @@ import qualified Ganeti.HTools.Node as Node import Ganeti.HTools.Types --- | Class for types which support show help and show version +-- | Class for types which support show help and show version. class CLIOptions a where + -- | Denotes whether the show help option has been passed. showHelp :: a -> Bool + -- | Denotes whether the show version option has been passed. showVersion :: a -> Bool --- | Class for types which support the -i/-n/-m options +-- | Class for types which support the -i\/-n\/-m options. class EToolOptions a where + -- | Returns the node file name. nodeFile :: a -> FilePath + -- | Tells whether the node file has been passed as an option. nodeSet :: a -> Bool + -- | Returns the instance file name. instFile :: a -> FilePath + -- | Tells whether the instance file has been passed as an option. instSet :: a -> Bool + -- | Rapi target, if one has been passed. masterName :: a -> String + -- | Whether to be less verbose. silent :: a -> Bool -- | Command line parser, using the 'options' structure. @@ -75,15 +83,16 @@ parseOpts argv progname options defaultOptions = where header = printf "%s %s\nUsage: %s [OPTION...]" progname Version.version progname --- | Parse the environment and return the node/instance names. --- This also hardcodes here the default node/instance file names. +-- | Parse the environment and return the node\/instance names. +-- +-- This also hardcodes here the default node\/instance file names. parseEnv :: () -> IO (String, String) parseEnv () = do a <- getEnvDefault "HTOOLS_NODES" "nodes" b <- getEnvDefault "HTOOLS_INSTANCES" "instances" return (a, b) --- | A shell script template for autogenerated scripts +-- | A shell script template for autogenerated scripts. shTemplate :: String shTemplate = printf "#!/bin/sh\n\n\ @@ -97,7 +106,7 @@ shTemplate = \ fi\n\ \}\n\n" --- | External tool data loader from a variety of sources +-- | External tool data loader from a variety of sources. loadExternalData :: (EToolOptions a) => a -> IO (Node.List, Instance.List, String)