diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-10-26 14:55:40 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-10-26 14:55:40 -0400 |
commit | 5de4482c1b52ead223bc380b45fcc421e25a80a4 (patch) | |
tree | 075091a3b866e28c906a3f7d44d20b2a4fcddd33 /Command | |
parent | 6580aa68ca335e66daab9a9c2b7f91ad6f9bd2cb (diff) |
enableremote: List uuids and descriptions of remotes that can be enabled, and accept either the uuid or the description in leu if the name.
Diffstat (limited to 'Command')
-rw-r--r-- | Command/EnableRemote.hs | 26 | ||||
-rw-r--r-- | Command/Info.hs | 3 |
2 files changed, 21 insertions, 8 deletions
diff --git a/Command/EnableRemote.hs b/Command/EnableRemote.hs index 84216dd78..b3ba451c2 100644 --- a/Command/EnableRemote.hs +++ b/Command/EnableRemote.hs @@ -12,6 +12,8 @@ import Command import qualified Logs.Remote import qualified Types.Remote as R import qualified Annex.SpecialRemote +import qualified Remote +import Logs.UUID import qualified Data.Map as M @@ -25,12 +27,19 @@ seek :: CmdParams -> CommandSeek seek = withWords start start :: [String] -> CommandStart -start [] = unknownNameError "Specify the name of the special remote to enable." +start [] = unknownNameError "Specify the special remote to enable." start (name:ws) = go =<< Annex.SpecialRemote.findExisting name where config = Logs.Remote.keyValToConfig ws - go Nothing = unknownNameError "Unknown special remote name." + go Nothing = do + m <- Annex.SpecialRemote.specialRemoteMap + confm <- Logs.Remote.readRemoteLog + v <- Remote.nameToUUID' name + case v of + Right u | u `M.member` m -> + go (Just (u, fromMaybe M.empty (M.lookup u confm))) + _ -> unknownNameError "Unknown special remote." go (Just (u, c)) = do let fullconfig = config `M.union` c t <- either error return (Annex.SpecialRemote.findType fullconfig) @@ -39,11 +48,14 @@ start (name:ws) = go =<< Annex.SpecialRemote.findExisting name unknownNameError :: String -> Annex a unknownNameError prefix = do - names <- Annex.SpecialRemote.remoteNames - error $ prefix ++ "\n" ++ - if null names - then "(No special remotes are currently known; perhaps use initremote instead?)" - else "Known special remotes: " ++ unwords names + m <- Annex.SpecialRemote.specialRemoteMap + descm <- M.unionWith Remote.addName <$> uuidMap <*> pure m + msg <- if M.null m + then pure "(No special remotes are currently known; perhaps use initremote instead?)" + else Remote.prettyPrintUUIDsDescs + "known special remotes" + descm (M.keys m) + error $ prefix ++ "\n" ++ msg perform :: RemoteType -> UUID -> R.RemoteConfig -> CommandPerform perform t u c = do diff --git a/Command/Info.hs b/Command/Info.hs index 25a537e8d..d22c23c04 100644 --- a/Command/Info.hs +++ b/Command/Info.hs @@ -427,8 +427,9 @@ reposizes_stats = stat desc $ nojson $ do . M.toList <$> cachedRepoData let maxlen = maximum (map (length . snd) l) + descm <- lift uuidDescriptions -- This also handles json display. - s <- lift $ prettyPrintUUIDsWith (Just "size") desc $ + s <- lift $ prettyPrintUUIDsWith (Just "size") desc descm $ map (\(u, sz) -> (u, Just $ mkdisp sz maxlen)) l return $ countRepoList (length l) s where |