move/copy: option parsing for --from with --to
authorJoey Hess <joeyh@joeyh.name>
Wed, 18 Jan 2023 18:42:39 +0000 (14:42 -0400)
committerJoey Hess <joeyh@joeyh.name>
Wed, 18 Jan 2023 18:42:39 +0000 (14:42 -0400)
commita6c1d9752b707fedb9bd4cf743742d1bf16538e7
treeb5b7c57244108dc237137c36a79865a3a98ad728
parent2a92f5cc2ced2f355bca462cf19a0a152a84f5c7
move/copy: option parsing for --from with --to

Allowing --from and --to as an alternative to --from or --to
is hard to do with optparse-applicative!

The obvious approach of (pfrom <|> pto <|> pfromandto) does not work
when pfromandto uses the same option names as pfrom and pto do.
It compiles but the generated parser does not work for all desired
combinations.

Instead, have to parse optionally from and optionally to. When neither
is provided, the parser succeeds, but it's a result that can't be
handled. So, have to giveup after option parsing. There does not seem to
be a way to make an optparse-applicative Parser give up internally
either.

Also, need seek' because I first tried making fto be a where binding,
but that resulted in a hang when git-annex move was run without --from
or --to. I think because startConcurrency was not expecting the stages
value to contain an exception and so ended up blocking.

Sponsored-by: Dartmouth College's DANDI project
CHANGELOG
CmdLine/GitAnnex/Options.hs
Command/Copy.hs
Command/Move.hs
doc/git-annex-copy.mdwn
doc/git-annex-move.mdwn