Revision daf0de68 htools/Ganeti/Common.hs

b/htools/Ganeti/Common.hs
228 228
    then exitSuccess
229 229
    else exitWith $ ExitFailure C.exitFailure
230 230

  
231
-- | Generates completion information for a multi-command binary.
232
multiCmdCompletion :: (StandardOptions a) => PersonalityList a -> String
233
multiCmdCompletion personalities =
234
  unlines .
235
  map argComplToText $
236
  map (\(cmd, _) -> ArgCompletion (OptComplChoices [cmd]) 1 (Just 1))
237
    personalities
238

  
239
-- | Displays completion information for a multi-command binary and exits.
240
showCmdCompletion :: (StandardOptions a) => PersonalityList a -> IO b
241
showCmdCompletion personalities =
242
  putStr (multiCmdCompletion personalities) >> exitSuccess
243

  
231 244
-- | Command line parser, using a generic 'Options' structure.
232 245
parseOpts :: (StandardOptions a) =>
233 246
             a                      -- ^ The default options
......
260 273
                  -- hardcoded option strings here!
261 274
                  "--version" -> putStrLn (versionInfo progname) >> exitSuccess
262 275
                  "--help"    -> usage True
276
                  "--help-completion" -> showCmdCompletion personalities
263 277
                  _           -> return c
264 278
  (cmd, cmd_args) <- case argv of
265 279
                       cmd:cmd_args -> do

Also available in: Unified diff