addunused, dropunused: Support --json and --json-error-messages
This also changes addunused to display the names of the files that it adds. That seems like a general usability improvement, and not displaying the input number does not seem likely to be a problem to a user, since the filename is based on the key. Displaying the filename was necessary to get it and the key included in the json. dropunused does not include the key in the json. It would be possible to add, but would need more changes. And I doubt that dropunused --json would be used in a situation where a program cared which keys were dropped. Note that drop --unused does have the key in its json, so such a program could just use it. Or could just dropkey --batch with the specific keys it wants to drop if it cares about specific keys. Sponsored-By: the NIH-funded NICEMAN (ReproNim TR&D3) project
This commit is contained in:
parent
972fd05688
commit
1a9af823bc
7 changed files with 69 additions and 39 deletions
|
@ -20,9 +20,10 @@ import Annex.Content
|
|||
import qualified Utility.RawFilePath as R
|
||||
|
||||
cmd :: Command
|
||||
cmd = command "dropunused" SectionMaintenance
|
||||
"drop unused file content"
|
||||
(paramRepeating paramNumRange) (seek <$$> optParser)
|
||||
cmd = withAnnexOptions [jsonOptions] $
|
||||
command "dropunused" SectionMaintenance
|
||||
"drop unused file content"
|
||||
(paramRepeating paramNumRange) (seek <$$> optParser)
|
||||
|
||||
data DropUnusedOptions = DropUnusedOptions
|
||||
{ rangesToDrop :: CmdParams
|
||||
|
@ -42,10 +43,15 @@ seek o = do
|
|||
withUnusedMaps (start from numcopies mincopies) (rangesToDrop o)
|
||||
|
||||
start :: Maybe Remote -> NumCopies -> MinCopies -> UnusedMaps -> Int -> CommandStart
|
||||
start from numcopies mincopies = startUnused "dropunused"
|
||||
(perform from numcopies mincopies)
|
||||
(performOther gitAnnexBadLocation)
|
||||
(performOther gitAnnexTmpObjectLocation)
|
||||
start from numcopies mincopies = startUnused
|
||||
(go (perform from numcopies mincopies))
|
||||
(go (performOther gitAnnexBadLocation))
|
||||
(go (performOther gitAnnexTmpObjectLocation))
|
||||
where
|
||||
go a n key = starting "dropunused"
|
||||
(ActionItemOther $ Just $ UnquotedString $ show n)
|
||||
(SeekInput [show n])
|
||||
(a key)
|
||||
|
||||
perform :: Maybe Remote -> NumCopies -> MinCopies -> Key -> CommandPerform
|
||||
perform from numcopies mincopies key = case from of
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue