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.
This commit is contained in:
parent
4a9e70c705
commit
aafaa363e3
4 changed files with 51 additions and 12 deletions
|
@ -103,6 +103,8 @@ paramSize :: String
|
||||||
paramSize = "SIZE"
|
paramSize = "SIZE"
|
||||||
paramAddress :: String
|
paramAddress :: String
|
||||||
paramAddress = "ADDRESS"
|
paramAddress = "ADDRESS"
|
||||||
|
paramItem :: String
|
||||||
|
paramItem = "ITEM"
|
||||||
paramKeyValue :: String
|
paramKeyValue :: String
|
||||||
paramKeyValue = "K=V"
|
paramKeyValue = "K=V"
|
||||||
paramNothing :: String
|
paramNothing :: String
|
||||||
|
|
|
@ -16,10 +16,11 @@ import Data.Tuple
|
||||||
import Data.Ord
|
import Data.Ord
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import qualified Remote
|
|
||||||
import qualified Command.Unused
|
import qualified Command.Unused
|
||||||
import qualified Git
|
import qualified Git
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
|
import qualified Remote
|
||||||
|
import qualified Types.Remote as Remote
|
||||||
import Command
|
import Command
|
||||||
import Utility.DataUnits
|
import Utility.DataUnits
|
||||||
import Utility.DiskFree
|
import Utility.DiskFree
|
||||||
|
@ -75,7 +76,7 @@ type StatState = StateT StatInfo Annex
|
||||||
|
|
||||||
cmd :: [Command]
|
cmd :: [Command]
|
||||||
cmd = [noCommit $ dontCheck repoExists $ withOptions [jsonOption] $
|
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"]
|
"shows information about the specified item or the repository as a whole"]
|
||||||
|
|
||||||
seek :: CommandSeek
|
seek :: CommandSeek
|
||||||
|
@ -99,11 +100,15 @@ globalInfo = do
|
||||||
itemInfo :: String -> Annex ()
|
itemInfo :: String -> Annex ()
|
||||||
itemInfo p = ifM (isdir p)
|
itemInfo p = ifM (isdir p)
|
||||||
( dirInfo 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
|
where
|
||||||
isdir = liftIO . catchBoolIO . (isDirectory <$$> getFileStatus)
|
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 :: FilePath -> Annex ()
|
||||||
dirInfo dir = showCustom (unwords ["info", dir]) $ do
|
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
|
evalStateT (mapM_ showStat (file_stats file k)) emptyStatInfo
|
||||||
return True
|
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 :: [Stat] -> [Stat] -> Annex [Stat]
|
||||||
selStats fast_stats slow_stats = do
|
selStats fast_stats slow_stats = do
|
||||||
fast <- Annex.getState Annex.fast
|
fast <- Annex.getState Annex.fast
|
||||||
|
@ -150,7 +160,7 @@ global_slow_stats =
|
||||||
]
|
]
|
||||||
dir_fast_stats :: [FilePath -> Stat]
|
dir_fast_stats :: [FilePath -> Stat]
|
||||||
dir_fast_stats =
|
dir_fast_stats =
|
||||||
[ local_dir
|
[ dir_name
|
||||||
, const local_annex_keys
|
, const local_annex_keys
|
||||||
, const local_annex_size
|
, const local_annex_size
|
||||||
, const known_annex_files
|
, const known_annex_files
|
||||||
|
@ -163,11 +173,19 @@ dir_slow_stats =
|
||||||
|
|
||||||
file_stats :: FilePath -> Key -> [Stat]
|
file_stats :: FilePath -> Key -> [Stat]
|
||||||
file_stats f k =
|
file_stats f k =
|
||||||
[ local_file f
|
[ file_name f
|
||||||
, key_size k
|
, key_size k
|
||||||
, key_name 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 :: String -> (String -> StatState String) -> Stat
|
||||||
stat desc a = return $ Just (desc, a desc)
|
stat desc a = return $ Just (desc, a desc)
|
||||||
|
|
||||||
|
@ -204,11 +222,26 @@ remote_list level = stat n $ nojson $ lift $ do
|
||||||
where
|
where
|
||||||
n = showTrustLevel level ++ " repositories"
|
n = showTrustLevel level ++ " repositories"
|
||||||
|
|
||||||
local_dir :: FilePath -> Stat
|
dir_name :: FilePath -> Stat
|
||||||
local_dir dir = stat "directory" $ json id $ return dir
|
dir_name dir = stat "directory" $ json id $ pure dir
|
||||||
|
|
||||||
local_file :: FilePath -> Stat
|
file_name :: FilePath -> Stat
|
||||||
local_file file = stat "file" $ json id $ return file
|
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
|
||||||
|
|
||||||
|
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 = stat "local annex keys" $ json show $
|
local_annex_keys = stat "local annex keys" $ json show $
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -13,6 +13,8 @@ git-annex (5.20141014) UNRELEASED; urgency=medium
|
||||||
* glacier: Fix pipe setup when calling glacier-cli to retrieve an object.
|
* 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
|
* info: When run on a single annexed file, displays some info about the
|
||||||
file, including its key and size.
|
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
|
-- Joey Hess <joeyh@debian.org> Tue, 14 Oct 2014 14:09:24 -0400
|
||||||
|
|
||||||
|
|
|
@ -676,10 +676,12 @@ subdirectories).
|
||||||
To generate output suitable for the gource visualization program,
|
To generate output suitable for the gource visualization program,
|
||||||
specify `--gource`.
|
specify `--gource`.
|
||||||
|
|
||||||
* `info [directory|file ...]`
|
* `info [directory|file|remote ...]`
|
||||||
|
|
||||||
Displays statistics and other information for the specified item,
|
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
|
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.
|
to select the files in the directory that are included in the statistics.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue