uninit: Support --json and --json-error-messages

Had to convert uninit to do everything that can error out inside a
CommandStart. This was harder than feels nice.

(Also, in passing, converted CommandCheck to use a data type, not a
weird number that it was not clear how it managed to be unique.)

Sponsored-By: the NIH-funded NICEMAN (ReproNim TR&D3) project
This commit is contained in:
Joey Hess 2023-05-11 13:36:59 -04:00
parent 1904cebbb3
commit 271f3b1ab4
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
7 changed files with 128 additions and 77 deletions

View file

@ -24,7 +24,7 @@ import Types.ActionItem
type CommandParser = Parser CommandSeek
{- b. The check stage runs checks, that error out if
- anything prevents the command from running. -}
data CommandCheck = CommandCheck { idCheck :: Int, runCheck :: Annex () }
data CommandCheck = CommandCheck { idCheck :: CommandCheckId, runCheck :: Annex () }
{- c. The seek stage is passed input from the parser, looks through
- the repo to find things to act on (ie, new files to add), and
- runs commandAction to handle all necessary actions. -}
@ -136,3 +136,10 @@ descSection SectionAddOn = "Addon commands"
newtype DryRun = DryRun Bool
deriving (Show)
data CommandCheckId
= CheckNotBareRepo
| RepoExists
| NoDaemonRunning
| GitAnnexShellOk
deriving (Show, Ord, Eq)