summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-01-26 15:53:01 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-01-26 15:53:01 -0400
commit541178b499d084e4041ae4b9d62bf86f5a97c3ff (patch)
treec47863a99db0631890802909583ac5003dda416f
parent257d1136e4178665fd52f14a2d430f9ad819d45f (diff)
refactor
-rw-r--r--Command/Drop.hs5
-rw-r--r--Command/DropKey.hs3
-rw-r--r--Command/Get.hs3
-rw-r--r--Command/Move.hs6
-rw-r--r--Command/Whereis.hs3
-rw-r--r--Messages.hs9
6 files changed, 13 insertions, 16 deletions
diff --git a/Command/Drop.hs b/Command/Drop.hs
index d17302035..0a6d61ba0 100644
--- a/Command/Drop.hs
+++ b/Command/Drop.hs
@@ -18,7 +18,6 @@ import Config.NumCopies
import Annex.Content
import qualified Option
import Annex.Wanted
-import Types.Key
def :: [Command]
def = [withOptions [fromOption] $ command "drop" paramPaths seek
@@ -45,12 +44,12 @@ start from file (key, _) = checkDropAuto from file key $ \numcopies ->
startLocal :: AssociatedFile -> NumCopies -> Key -> Maybe Remote -> CommandStart
startLocal afile numcopies key knownpresentremote = stopUnless (inAnnex key) $ do
- showStart "drop" (fromMaybe (key2file key) afile)
+ showStart' "drop" key afile
next $ performLocal key numcopies knownpresentremote
startRemote :: AssociatedFile -> NumCopies -> Key -> Remote -> CommandStart
startRemote afile numcopies key remote = do
- showStart ("drop " ++ Remote.name remote) (fromMaybe (key2file key) afile)
+ showStart' ("drop " ++ Remote.name remote) key afile
next $ performRemote key numcopies remote
performLocal :: Key -> NumCopies -> Maybe Remote -> CommandPerform
diff --git a/Command/DropKey.hs b/Command/DropKey.hs
index 002633e58..125e6ded4 100644
--- a/Command/DropKey.hs
+++ b/Command/DropKey.hs
@@ -12,7 +12,6 @@ import Command
import qualified Annex
import Logs.Location
import Annex.Content
-import Types.Key
def :: [Command]
def = [noCommit $ command "dropkey" (paramRepeating paramKey) seek
@@ -25,7 +24,7 @@ start :: Key -> CommandStart
start key = stopUnless (inAnnex key) $ do
unlessM (Annex.getState Annex.force) $
error "dropkey can cause data loss; use --force if you're sure you want to do this"
- showStart "dropkey" (key2file key)
+ showStart' "dropkey" key Nothing
next $ perform key
perform :: Key -> CommandPerform
diff --git a/Command/Get.hs b/Command/Get.hs
index fb2145fdd..edab72e42 100644
--- a/Command/Get.hs
+++ b/Command/Get.hs
@@ -16,7 +16,6 @@ import Config.NumCopies
import Annex.Wanted
import GitAnnex.Options
import qualified Command.Move
-import Types.Key
def :: [Command]
def = [withOptions getOptions $ command "get" paramPaths seek
@@ -51,7 +50,7 @@ start' expensivecheck from key afile = stopUnless (not <$> inAnnex key) $
go $ Command.Move.fromPerform src False key afile
where
go a = do
- showStart "get" (fromMaybe (key2file key) afile)
+ showStart' "get" key afile
next a
perform :: Key -> AssociatedFile -> CommandPerform
diff --git a/Command/Move.hs b/Command/Move.hs
index b7b567812..682fb5296 100644
--- a/Command/Move.hs
+++ b/Command/Move.hs
@@ -17,7 +17,6 @@ import Annex.UUID
import Logs.Presence
import Logs.Transfer
import GitAnnex.Options
-import Types.Key
def :: [Command]
def = [withOptions moveOptions $ command "move" paramPaths seek
@@ -54,10 +53,7 @@ start' to from move afile key = do
"--auto is not supported for move"
showMoveAction :: Bool -> Key -> AssociatedFile -> Annex ()
-showMoveAction True _ (Just file) = showStart "move" file
-showMoveAction False _ (Just file) = showStart "copy" file
-showMoveAction True key Nothing = showStart "move" (key2file key)
-showMoveAction False key Nothing = showStart "copy" (key2file key)
+showMoveAction move = showStart' (if move then "move" else "copy")
{- Moves (or copies) the content of an annexed file to a remote.
-
diff --git a/Command/Whereis.hs b/Command/Whereis.hs
index 0083f8c5c..723509fb1 100644
--- a/Command/Whereis.hs
+++ b/Command/Whereis.hs
@@ -14,7 +14,6 @@ import Command
import Remote
import Logs.Trust
import GitAnnex.Options
-import Types.Key
def :: [Command]
def = [noCommit $ withOptions (jsonOption : keyOptions) $
@@ -37,7 +36,7 @@ startKeys remotemap key = start' remotemap key Nothing
start' :: M.Map UUID Remote -> Key -> AssociatedFile -> CommandStart
start' remotemap key afile = do
- showStart "whereis" (fromMaybe (key2file key) afile)
+ showStart' "whereis" key afile
next $ perform remotemap key
perform :: M.Map UUID Remote -> Key -> CommandPerform
diff --git a/Messages.hs b/Messages.hs
index 0357da12d..9f473110a 100644
--- a/Messages.hs
+++ b/Messages.hs
@@ -1,12 +1,13 @@
{- git-annex output messages
-
- - Copyright 2010-2011 Joey Hess <joey@kitenet.net>
+ - Copyright 2010-2014 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Messages (
showStart,
+ showStart',
showNote,
showAction,
showProgress,
@@ -54,10 +55,14 @@ import Types.Key
import qualified Annex
import Utility.Metered
-showStart :: String -> String -> Annex ()
+showStart :: String -> FilePath -> Annex ()
showStart command file = handle (JSON.start command $ Just file) $
flushed $ putStr $ command ++ " " ++ file ++ " "
+showStart' :: String -> Key -> Maybe FilePath -> Annex ()
+showStart' command key afile = showStart command $
+ fromMaybe (key2file key) afile
+
showNote :: String -> Annex ()
showNote s = handle (JSON.note s) $
flushed $ putStr $ "(" ++ s ++ ") "