initial implementation of --explain

Currently it only displays explanations of options like --in and --copies.

In the future, it should explain preferred content expression evaluation
and other decisions.

The explanations of a few things could be better. In particular,
"standard" will just appear as-is (or as "!standard" if it doesn't
match), rather than explaining why the standard preferred content expression
for the group matches or not.

Currently as implemented, it goes to stdout, and so commands like
git-annex find that have custom output will not display --explain
information. Perhaps that should change, dunno.

Sponsored-by: Dartmouth College's DANDI project
This commit is contained in:
Joey Hess 2023-07-25 16:11:06 -04:00
parent cf40e2d4b6
commit f25eeedeac
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
12 changed files with 122 additions and 46 deletions

View file

@ -286,12 +286,12 @@ keyMatchingOptions' =
<> help "skip files with fewer copies"
<> hidden
)
, annexOption (setAnnexState . Limit.addLackingCopies False) $ strOption
, annexOption (setAnnexState . Limit.addLackingCopies "lackingcopies" False) $ strOption
( long "lackingcopies" <> metavar paramNumber
<> help "match files that need more copies"
<> hidden
)
, annexOption (setAnnexState . Limit.addLackingCopies True) $ strOption
, annexOption (setAnnexState . Limit.addLackingCopies "approxlackingcopies" True) $ strOption
( long "approxlackingcopies" <> metavar paramNumber
<> help "match files that need more copies (faster)"
<> hidden

View file

@ -59,6 +59,11 @@ commonOptions =
<> help "show debug messages coming from the specified module"
<> hidden
)
, annexFlag (setexplain True)
( long "explain" <> short 'd'
<> help "explain why git-annex does what it does"
<> hidden
)
]
where
setforce v = setAnnexRead $ \rd -> rd { Annex.force = v }
@ -82,5 +87,9 @@ commonOptions =
decodeBS (debugfilterconfig <> "=") ++ v
]
setexplain v = mconcat
[ setAnnexRead $ \rd -> rd { Annex.explainenabled = v }
]
(ConfigKey debugconfig) = annexConfig "debug"
(ConfigKey debugfilterconfig) = annexConfig "debugfilter"