aboutsummaryrefslogtreecommitdiff
path: root/CmdLine
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2018-02-19 14:28:17 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2018-02-19 14:32:15 -0400
commitec1e50642b62fa3dcf5a2c9f7fd582e403c17627 (patch)
tree96463a73c79b274cc8f54123719f292547faa0ad /CmdLine
parent0366c6eac698327ced9c63e241a9474a5c2a7e20 (diff)
add --json-error-messages (not yet implemented)
Added --json-error-messages option, which includes error messages in the json output, rather than outputting them to stderr. The actual rediretion of errors is not implemented yet, this is only the docs and option plumbing. This commit was supported by the NSF-funded DataLad project.
Diffstat (limited to 'CmdLine')
-rw-r--r--CmdLine/GitAnnex/Options.hs70
1 files changed, 43 insertions, 27 deletions
diff --git a/CmdLine/GitAnnex/Options.hs b/CmdLine/GitAnnex/Options.hs
index 51c55b056..143bb6498 100644
--- a/CmdLine/GitAnnex/Options.hs
+++ b/CmdLine/GitAnnex/Options.hs
@@ -191,7 +191,7 @@ annexedMatchingOptions = concat
[ nonWorkTreeMatchingOptions'
, fileMatchingOptions'
, combiningOptions
- , [timeLimitOption]
+ , timeLimitOption
]
-- Matching options that don't need to examine work tree files.
@@ -294,37 +294,51 @@ combiningOptions =
longopt o h = globalFlag (Limit.addToken o) ( long o <> help h <> hidden )
shortopt o h = globalFlag (Limit.addToken [o]) ( short o <> help h <> hidden )
-jsonOption :: GlobalOption
-jsonOption = globalFlag (Annex.setOutput (JSONOutput jsonoptions))
- ( long "json" <> short 'j'
- <> help "enable JSON output"
- <> hidden
- )
+jsonOptions :: [GlobalOption]
+jsonOptions =
+ [ globalFlag (Annex.setOutput (JSONOutput stdjsonoptions))
+ ( long "json" <> short 'j'
+ <> help "enable JSON output"
+ <> hidden
+ )
+ , globalFlag (Annex.setOutput (JSONOutput jsonerrormessagesoptions))
+ ( long "json-error-messages"
+ <> help "include error messages in JSON"
+ <> hidden
+ )
+ ]
where
- jsonoptions = JSONOptions
+ stdjsonoptions = JSONOptions
{ jsonProgress = False
+ , jsonErrorMessages = False
}
+ jsonerrormessagesoptions = stdjsonoptions { jsonErrorMessages = True }
-jsonProgressOption :: GlobalOption
-jsonProgressOption = globalFlag (Annex.setOutput (JSONOutput jsonoptions))
- ( long "json-progress"
- <> help "include progress in JSON output"
- <> hidden
- )
+jsonProgressOption :: [GlobalOption]
+jsonProgressOption =
+ [ globalFlag (Annex.setOutput (JSONOutput jsonoptions))
+ ( long "json-progress"
+ <> help "include progress in JSON output"
+ <> hidden
+ )
+ ]
where
jsonoptions = JSONOptions
{ jsonProgress = True
+ , jsonErrorMessages = False
}
-- Note that a command that adds this option should wrap its seek
-- action in `allowConcurrentOutput`.
-jobsOption :: GlobalOption
-jobsOption = globalSetter set $
- option auto
- ( long "jobs" <> short 'J' <> metavar paramNumber
- <> help "enable concurrent jobs"
- <> hidden
- )
+jobsOption :: [GlobalOption]
+jobsOption =
+ [ globalSetter set $
+ option auto
+ ( long "jobs" <> short 'J' <> metavar paramNumber
+ <> help "enable concurrent jobs"
+ <> hidden
+ )
+ ]
where
set n = do
Annex.changeState $ \s -> s { Annex.concurrency = Concurrent n }
@@ -332,12 +346,14 @@ jobsOption = globalSetter set $
when (n > c) $
liftIO $ setNumCapabilities n
-timeLimitOption :: GlobalOption
-timeLimitOption = globalSetter Limit.addTimeLimit $ strOption
- ( long "time-limit" <> short 'T' <> metavar paramTime
- <> help "stop after the specified amount of time"
- <> hidden
- )
+timeLimitOption :: [GlobalOption]
+timeLimitOption =
+ [ globalSetter Limit.addTimeLimit $ strOption
+ ( long "time-limit" <> short 'T' <> metavar paramTime
+ <> help "stop after the specified amount of time"
+ <> hidden
+ )
+ ]
data DaemonOptions = DaemonOptions
{ foregroundDaemonOption :: Bool