From 3483595622432eec1df905b24faa0f3f48d507de Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 20 Feb 2017 16:37:04 -0400 Subject: status: Pass --ignore-submodules=when option on to git status. Didn't make --ignore-submodules without a value be handled because I can't see a way to make optparse-applicative parse that. I've opened a bug requesting a way to do that: https://github.com/pcapriotti/optparse-applicative/issues/243 --- Command/Status.hs | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'Command/Status.hs') diff --git a/Command/Status.hs b/Command/Status.hs index 3a3bfa812..2e6b9f44a 100644 --- a/Command/Status.hs +++ b/Command/Status.hs @@ -20,14 +20,28 @@ cmd = notBareRepo $ noCommit $ noMessages $ withGlobalOptions [jsonOption] $ command "status" SectionCommon "show the working tree status" - paramPaths (withParams seek) + paramPaths (seek <$$> optParser) -seek :: CmdParams -> CommandSeek -seek = withWords start +data StatusOptions = StatusOptions + { statusFiles :: CmdParams + , ignoreSubmodules :: Maybe String + } + +optParser :: CmdParamsDesc -> Parser StatusOptions +optParser desc = StatusOptions + <$> cmdParams desc + <*> optional (strOption + ( long "ignore-submodules" + <> help "passed on to git status" + <> metavar "WHEN" + )) + +seek :: StatusOptions -> CommandSeek +seek o = withWords (start o) (statusFiles o) -start :: [FilePath] -> CommandStart -start locs = do - (l, cleanup) <- inRepo $ getStatus locs +start :: StatusOptions -> [FilePath] -> CommandStart +start o locs = do + (l, cleanup) <- inRepo $ getStatus ps locs getstatus <- ifM isDirect ( return statusDirect , return $ \s -> pure (Just s) @@ -35,6 +49,10 @@ start locs = do forM_ l $ \s -> maybe noop displayStatus =<< getstatus s void $ liftIO cleanup stop + where + ps = case ignoreSubmodules o of + Nothing -> [] + Just s -> [Param $ "--ignore-submodules="++s] displayStatus :: Status -> Annex () -- renames not shown in this simplified status -- cgit v1.2.3