status: Support --json.
This commit is contained in:
parent
babd03d252
commit
456c9eedb0
3 changed files with 15 additions and 7 deletions
|
@ -15,9 +15,10 @@ import Config
|
||||||
import qualified Git.LsFiles as LsFiles
|
import qualified Git.LsFiles as LsFiles
|
||||||
import qualified Git.Ref
|
import qualified Git.Ref
|
||||||
import qualified Git
|
import qualified Git
|
||||||
|
import GitAnnex.Options
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [notBareRepo $ noCommit $ noMessages $
|
def = [notBareRepo $ noCommit $ noMessages $ withOptions [jsonOption] $
|
||||||
command "status" paramPaths seek SectionCommon
|
command "status" paramPaths seek SectionCommon
|
||||||
"show the working tree status"]
|
"show the working tree status"]
|
||||||
|
|
||||||
|
@ -32,11 +33,11 @@ start [] = do
|
||||||
-- given the path to the top of the repository.
|
-- given the path to the top of the repository.
|
||||||
cwd <- liftIO getCurrentDirectory
|
cwd <- liftIO getCurrentDirectory
|
||||||
top <- fromRepo Git.repoPath
|
top <- fromRepo Git.repoPath
|
||||||
next $ perform [relPathDirToFile cwd top]
|
start' [relPathDirToFile cwd top]
|
||||||
start locs = next $ perform locs
|
start locs = start' locs
|
||||||
|
|
||||||
perform :: [FilePath] -> CommandPerform
|
start' :: [FilePath] -> CommandStart
|
||||||
perform locs = do
|
start' locs = do
|
||||||
(l, cleanup) <- inRepo $ LsFiles.modifiedOthers locs
|
(l, cleanup) <- inRepo $ LsFiles.modifiedOthers locs
|
||||||
getstatus <- ifM isDirect
|
getstatus <- ifM isDirect
|
||||||
( return statusDirect
|
( return statusDirect
|
||||||
|
@ -44,7 +45,7 @@ perform locs = do
|
||||||
)
|
)
|
||||||
forM_ l $ \f -> maybe noop (showFileStatus f) =<< getstatus f
|
forM_ l $ \f -> maybe noop (showFileStatus f) =<< getstatus f
|
||||||
void $ liftIO cleanup
|
void $ liftIO cleanup
|
||||||
next $ return True
|
stop
|
||||||
|
|
||||||
data Status
|
data Status
|
||||||
= NewFile
|
= NewFile
|
||||||
|
@ -57,7 +58,10 @@ showStatus DeletedFile = "D"
|
||||||
showStatus ModifiedFile = "M"
|
showStatus ModifiedFile = "M"
|
||||||
|
|
||||||
showFileStatus :: FilePath -> Status -> Annex ()
|
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 :: FilePath -> Annex (Maybe Status)
|
||||||
statusDirect f = checkstatus =<< liftIO (catchMaybeIO $ getFileStatus f)
|
statusDirect f = checkstatus =<< liftIO (catchMaybeIO $ getFileStatus f)
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -1,6 +1,7 @@
|
||||||
git-annex (5.20140118) UNRELEASED; urgency=medium
|
git-annex (5.20140118) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
* Remove --json option from commands not supporting it.
|
* Remove --json option from commands not supporting it.
|
||||||
|
* status: Support --json.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Sat, 18 Jan 2014 11:54:17 -0400
|
-- Joey Hess <joeyh@debian.org> Sat, 18 Jan 2014 11:54:17 -0400
|
||||||
|
|
||||||
|
|
|
@ -29,3 +29,6 @@ Debian sid 5.20140116
|
||||||
|
|
||||||
# End of transcript or log.
|
# 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]]
|
||||||
|
|
Loading…
Reference in a new issue