adjust: Allow any order of options when combining --hide-missing with options like --unlock.
optparse-applicative made this hard, the naive implementation this had before didn't let --hide-missing come after --unlock. And just adding additional <|> with --hide-missing coming after --unlock didn't work either. So need to get some options and then combine them.
This commit is contained in:
parent
2c14181bcb
commit
bdf3a4747f
4 changed files with 22 additions and 7 deletions
|
@ -10,6 +10,8 @@ git-annex (10.20240928) UNRELEASED; urgency=medium
|
|||
allowing building with ghc 9.0.2.
|
||||
* git-remote-annex: Fix bug that prevented using it with external special
|
||||
remotes, leading to protocol error messages involving "GITMANIFEST".
|
||||
* adjust: Allow any order of options when combining --hide-missing with
|
||||
options like --unlock.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Thu, 17 Oct 2024 11:02:17 -0400
|
||||
|
||||
|
|
|
@ -17,9 +17,24 @@ cmd = notBareRepo $ noDaemonRunning $
|
|||
|
||||
optParser :: CmdParamsDesc -> Parser Adjustment
|
||||
optParser _ =
|
||||
(LinkAdjustment <$> linkAdjustmentParser)
|
||||
<|> (PresenceAdjustment <$> presenceAdjustmentParser <*> maybeLinkAdjustmentParser)
|
||||
linkPresentAdjustmentParser
|
||||
<|> (LockUnlockPresentAdjustment <$> lockUnlockPresentAdjustmentParser)
|
||||
|
||||
linkPresentAdjustmentParser :: Parser Adjustment
|
||||
linkPresentAdjustmentParser = comb <$> some ps
|
||||
where
|
||||
ps = (LinkAdjustment <$> linkAdjustmentParser)
|
||||
<|> (PresenceAdjustment <$> presenceAdjustmentParser <*> pure Nothing)
|
||||
comb (LinkAdjustment _ : LinkAdjustment b : c) =
|
||||
comb (LinkAdjustment b : c)
|
||||
comb (PresenceAdjustment _a1 a2 : PresenceAdjustment b1 b2 : c) =
|
||||
comb (PresenceAdjustment b1 (b2 <|> a2) : c)
|
||||
comb (LinkAdjustment a : PresenceAdjustment b1 b2 : c) =
|
||||
comb (PresenceAdjustment b1 (b2 <|> Just a) : c)
|
||||
comb (PresenceAdjustment a1 _a2 : LinkAdjustment b : c) =
|
||||
comb (PresenceAdjustment a1 (Just b) : c)
|
||||
comb (a : _) = a
|
||||
comb [] = error "internal"
|
||||
|
||||
linkAdjustmentParser :: Parser LinkAdjustment
|
||||
linkAdjustmentParser =
|
||||
|
@ -36,9 +51,6 @@ linkAdjustmentParser =
|
|||
<> help "fix symlinks to annnexed files"
|
||||
)
|
||||
|
||||
maybeLinkAdjustmentParser :: Parser (Maybe LinkAdjustment)
|
||||
maybeLinkAdjustmentParser = Just <$> linkAdjustmentParser <|> pure Nothing
|
||||
|
||||
presenceAdjustmentParser :: Parser PresenceAdjustment
|
||||
presenceAdjustmentParser =
|
||||
flag' HideMissingAdjustment
|
||||
|
|
|
@ -40,3 +40,5 @@ This is admittedly arguably consistent with https://git-annex.branchable.com/git
|
|||
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
|
||||
|
||||
Yes, I've been really happy using it to manage a bunch of videos, where I only need some on my laptop at any given time. Way better than my previous "manually scp things around" strategy.
|
||||
|
||||
> [[fixed|done]] --[[Joey]]
|
||||
|
|
|
@ -3,6 +3,5 @@
|
|||
subject="""comment 1"""
|
||||
date="2024-10-21T19:06:47Z"
|
||||
content="""
|
||||
This is not intentional behavior, and is surprising. I don't think an
|
||||
applicative option parser should ever behave this way. Weird!
|
||||
Surprising and unintentional! Fixed this.
|
||||
"""]]
|
||||
|
|
Loading…
Reference in a new issue