diff options
author | Joey Hess <joey@kitenet.net> | 2014-10-21 13:44:17 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-10-21 14:35:07 -0400 |
commit | 19e96c4dcf8cf6e78dcc78527530279f205caf98 (patch) | |
tree | 02f15841f1dbd68297b399d49a211879d589d6a0 | |
parent | 025c8e0d6e4c0037296968a828a6b57148f8e5e5 (diff) |
info: When passed the name or uuid of a remote, displays info about that remote.
No per-remote-type info yet.
This commit was sponsored by Stanley Yamane.
-rw-r--r-- | CmdLine/Usage.hs | 2 | ||||
-rw-r--r-- | Command/Info.hs | 53 | ||||
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | doc/git-annex.mdwn | 6 |
4 files changed, 51 insertions, 12 deletions
diff --git a/CmdLine/Usage.hs b/CmdLine/Usage.hs index 6e0a1ca80..1998a5f54 100644 --- a/CmdLine/Usage.hs +++ b/CmdLine/Usage.hs @@ -103,6 +103,8 @@ paramSize :: String paramSize = "SIZE" paramAddress :: String paramAddress = "ADDRESS" +paramItem :: String +paramItem = "ITEM" paramKeyValue :: String paramKeyValue = "K=V" paramNothing :: String diff --git a/Command/Info.hs b/Command/Info.hs index ffa6a591e..5cac2954a 100644 --- a/Command/Info.hs +++ b/Command/Info.hs @@ -16,10 +16,11 @@ import Data.Tuple import Data.Ord import Common.Annex -import qualified Remote import qualified Command.Unused import qualified Git import qualified Annex +import qualified Remote +import qualified Types.Remote as Remote import Command import Utility.DataUnits import Utility.DiskFree @@ -75,7 +76,7 @@ type StatState = StateT StatInfo Annex cmd :: [Command] cmd = [noCommit $ dontCheck repoExists $ withOptions [jsonOption] $ - command "info" paramPaths seek SectionQuery + command "info" (paramOptional $ paramRepeating paramItem) seek SectionQuery "shows information about the specified item or the repository as a whole"] seek :: CommandSeek @@ -99,11 +100,15 @@ globalInfo = do itemInfo :: String -> Annex () itemInfo p = ifM (isdir p) ( dirInfo p - , maybe noinfo (fileInfo p) =<< isAnnexLink p + , do + v <- Remote.byName' p + case v of + Right r -> remoteInfo r + Left _ -> maybe noinfo (fileInfo p) =<< isAnnexLink p ) where isdir = liftIO . catchBoolIO . (isDirectory <$$> getFileStatus) - noinfo = error $ p ++ " is not a directory or an annexed file" + noinfo = error $ p ++ " is not a directory or an annexed file or a remote" dirInfo :: FilePath -> Annex () dirInfo dir = showCustom (unwords ["info", dir]) $ do @@ -118,6 +123,11 @@ fileInfo file k = showCustom (unwords ["info", file]) $ do evalStateT (mapM_ showStat (file_stats file k)) emptyStatInfo return True +remoteInfo :: Remote -> Annex () +remoteInfo r = showCustom (unwords ["info", Remote.name r]) $ do + evalStateT (mapM_ showStat (remote_stats r)) emptyStatInfo + return True + selStats :: [Stat] -> [Stat] -> Annex [Stat] selStats fast_stats slow_stats = do fast <- Annex.getState Annex.fast @@ -150,7 +160,7 @@ global_slow_stats = ] dir_fast_stats :: [FilePath -> Stat] dir_fast_stats = - [ local_dir + [ dir_name , const local_annex_keys , const local_annex_size , const known_annex_files @@ -163,11 +173,19 @@ dir_slow_stats = file_stats :: FilePath -> Key -> [Stat] file_stats f k = - [ local_file f + [ file_name f , key_size k , key_name k ] +remote_stats :: Remote -> [Stat] +remote_stats r = + [ remote_name r + , remote_description r + , remote_uuid r + , remote_cost r + ] + stat :: String -> (String -> StatState String) -> Stat stat desc a = return $ Just (desc, a desc) @@ -204,11 +222,26 @@ remote_list level = stat n $ nojson $ lift $ do where n = showTrustLevel level ++ " repositories" -local_dir :: FilePath -> Stat -local_dir dir = stat "directory" $ json id $ return dir +dir_name :: FilePath -> Stat +dir_name dir = stat "directory" $ json id $ pure dir + +file_name :: FilePath -> Stat +file_name file = stat "file" $ json id $ pure file + +remote_name :: Remote -> Stat +remote_name r = stat "remote" $ json id $ pure (Remote.name r) + +remote_description :: Remote -> Stat +remote_description r = stat "description" $ json id $ lift $ + Remote.prettyUUID (Remote.uuid r) + +remote_uuid :: Remote -> Stat +remote_uuid r = stat "uuid" $ json id $ pure $ + fromUUID $ Remote.uuid r -local_file :: FilePath -> Stat -local_file file = stat "file" $ json id $ return file +remote_cost :: Remote -> Stat +remote_cost r = stat "cost" $ json id $ pure $ + show $ Remote.cost r local_annex_keys :: Stat local_annex_keys = stat "local annex keys" $ json show $ diff --git a/debian/changelog b/debian/changelog index 6b3b59b83..35277539f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,8 @@ git-annex (5.20141014) UNRELEASED; urgency=medium * glacier: Fix pipe setup when calling glacier-cli to retrieve an object. * info: When run on a single annexed file, displays some info about the file, including its key and size. + * info: When passed the name or uuid of a remote, displays info about that + remote. -- Joey Hess <joeyh@debian.org> Tue, 14 Oct 2014 14:09:24 -0400 diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index 95d8e14c5..7df4ecb3f 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -676,10 +676,12 @@ subdirectories). To generate output suitable for the gource visualization program, specify `--gource`. -* `info [directory|file ...]` +* `info [directory|file|remote ...]` Displays statistics and other information for the specified item, - or if none is specified, for the repository as a whole. + which can be a directory, or a file, or a remote (specified by name or + UUID). When no item is specified, displays statistics and information + for the repository as a whole. When a directory is specified, the file matching options can be used to select the files in the directory that are included in the statistics. |