From 456c9eedb014721ac3ae25ce9e931a8e50e1c248 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 18 Jan 2014 12:05:10 -0400 Subject: [PATCH] status: Support --json. --- Command/Status.hs | 18 +++++++++++------- debian/changelog | 1 + doc/bugs/--json_is_broken_for_status.mdwn | 3 +++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Command/Status.hs b/Command/Status.hs index 5dc6259947..27127b3ecf 100644 --- a/Command/Status.hs +++ b/Command/Status.hs @@ -15,9 +15,10 @@ import Config import qualified Git.LsFiles as LsFiles import qualified Git.Ref import qualified Git +import GitAnnex.Options def :: [Command] -def = [notBareRepo $ noCommit $ noMessages $ +def = [notBareRepo $ noCommit $ noMessages $ withOptions [jsonOption] $ command "status" paramPaths seek SectionCommon "show the working tree status"] @@ -32,11 +33,11 @@ start [] = do -- given the path to the top of the repository. cwd <- liftIO getCurrentDirectory top <- fromRepo Git.repoPath - next $ perform [relPathDirToFile cwd top] -start locs = next $ perform locs + start' [relPathDirToFile cwd top] +start locs = start' locs -perform :: [FilePath] -> CommandPerform -perform locs = do +start' :: [FilePath] -> CommandStart +start' locs = do (l, cleanup) <- inRepo $ LsFiles.modifiedOthers locs getstatus <- ifM isDirect ( return statusDirect @@ -44,7 +45,7 @@ perform locs = do ) forM_ l $ \f -> maybe noop (showFileStatus f) =<< getstatus f void $ liftIO cleanup - next $ return True + stop data Status = NewFile @@ -57,7 +58,10 @@ showStatus DeletedFile = "D" showStatus ModifiedFile = "M" showFileStatus :: FilePath -> Status -> Annex () -showFileStatus f s = liftIO $ putStrLn $ showStatus s ++ " " ++ f +showFileStatus f s = unlessM (showFullJSON [("status", ss), ("file", f)]) $ + liftIO $ putStrLn $ ss ++ " " ++ f + where + ss = showStatus s statusDirect :: FilePath -> Annex (Maybe Status) statusDirect f = checkstatus =<< liftIO (catchMaybeIO $ getFileStatus f) diff --git a/debian/changelog b/debian/changelog index 3dac771513..0d60200942 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ git-annex (5.20140118) UNRELEASED; urgency=medium * Remove --json option from commands not supporting it. + * status: Support --json. -- Joey Hess Sat, 18 Jan 2014 11:54:17 -0400 diff --git a/doc/bugs/--json_is_broken_for_status.mdwn b/doc/bugs/--json_is_broken_for_status.mdwn index ef67a413b5..0ce9dc7fa1 100644 --- a/doc/bugs/--json_is_broken_for_status.mdwn +++ b/doc/bugs/--json_is_broken_for_status.mdwn @@ -29,3 +29,6 @@ Debian sid 5.20140116 # End of transcript or log. """]] + +> Not all commands support json. Made this explict by making --json not be +> a global option. Added --json support to status. [[done]]. --[[Joey]]