Commit 7ce2f8ee authored by Michele Tartara's avatar Michele Tartara

Fix a bug in the generation of completion information

Completion information for multi-command binaries were not generated in
the correct way, so the build-bash-complation script failed when such a
binary was actually found.

This commit fixes this issue, and a related docstring typo as well.
Signed-off-by: default avatarMichele Tartara <mtartara@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent c46a9ffb
......@@ -117,7 +117,7 @@ complToText compl =
stripped = stripPrefix "OptCompl" show_compl
in map toLower $ fromMaybe show_compl stripped
-- | Tex serialisation for 'ArgCompletion'.
-- | Text serialisation for 'ArgCompletion'.
argComplToText :: ArgCompletion -> String
argComplToText (ArgCompletion optc min_cnt max_cnt) =
complToText optc ++ " " ++ show min_cnt ++ " " ++ maybe "none" show max_cnt
......@@ -236,15 +236,14 @@ showCmdUsage prog personalities success = do
-- | Generates completion information for a multi-command binary.
multiCmdCompletion :: (StandardOptions a) => PersonalityList a -> String
multiCmdCompletion personalities =
unlines .
map argComplToText $
map (\(cmd, _) -> ArgCompletion (OptComplChoices [cmd]) 1 (Just 1))
personalities
argComplToText $
ArgCompletion (OptComplChoices (map fst personalities))
1 (Just 1)
-- | Displays completion information for a multi-command binary and exits.
showCmdCompletion :: (StandardOptions a) => PersonalityList a -> IO b
showCmdCompletion personalities =
putStr (multiCmdCompletion personalities) >> exitSuccess
putStrLn (multiCmdCompletion personalities) >> exitSuccess
-- | Command line parser, using a generic 'Options' structure.
parseOpts :: (StandardOptions a) =>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment