enableremote: List uuids and descriptions of remotes that can be enabled, and accept either the uuid or the description in leu if the name.

This commit is contained in:
Joey Hess 2015-10-26 14:55:40 -04:00
parent 016904f424
commit 640dba43b6
Failed to extract signature
7 changed files with 75 additions and 25 deletions

View file

@ -42,10 +42,14 @@ findByName n = filter (matching . snd) . M.toList
| n' == n -> True
| otherwise -> False
remoteNames :: Annex [RemoteName]
remoteNames = do
specialRemoteMap :: Annex (M.Map UUID RemoteName)
specialRemoteMap = do
m <- Logs.Remote.readRemoteLog
return $ mapMaybe (M.lookup nameKey . snd) $ M.toList m
return $ M.fromList $ mapMaybe go (M.toList m)
where
go (u, c) = case M.lookup nameKey c of
Nothing -> Nothing
Just n -> Just (u, n)
{- find the specified remote type -}
findType :: RemoteConfig -> Either String RemoteType