renameremote: Better handling of case where there are multiple special remotes with a name

Instead of renaming one at random, error out and ask that a uuid be
specified.

Sponsored-by: Brett Eisenberg on Patreon
This commit is contained in:
Joey Hess 2022-01-05 15:24:02 -04:00
parent 58afb00f6e
commit e416635021
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 16 additions and 15 deletions

View file

@ -64,7 +64,7 @@ seek o = withWords (commandAction . (start o)) (cmdparams o)
start :: InitRemoteOptions -> [String] -> CommandStart
start _ [] = giveup "Specify a name for the remote."
start o (name:ws) = ifM (isJust <$> findExisting name)
start o (name:ws) = ifM (not . null <$> findExisting name)
( giveup $ "There is already a special remote named \"" ++ name ++
"\". (Use enableremote to enable an existing special remote.)"
, ifM (isJust <$> Remote.byNameOnly name)