You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to implement cp-like behavior, where many arguments are parsed as source and then the last one as destination. But this fails with optparse-applicative. The only way which works is to swap the order: have one argument followed by many args.
So, this works:
ghci> execParserMaybe (info ((,) <$> (strArgument mempty) <*> many (strArgument mempty)) mempty) $ ["a", "b", "c"]
Just ("a",["b","c"])
I don't have a great answer for this. It's like in Text.Parsec or Data.Attoparsec saying: let a = (,) <$> many anyChar <*> anyChar
You'll never reach the last char as the many is too greedy. It's possible to do this with a lookahead in Parsec, but that's something rather heavy for a command line parser.
(remember too that you can always take the init and last from the parsed args list)
@w3rs I would suggest using a single many argument and then simply take the last item from the resulting list and strip off the last item of the list and give it whatever different treatment you need.
I want to implement
cp
-like behavior, wheremany
arguments are parsed as source and then the last one as destination. But this fails with optparse-applicative. The only way which works is to swap the order: have one argument followed bymany
args.So, this works:
But this doesn't:
The text was updated successfully, but these errors were encountered: