<div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Date: Fri, 4 Feb 2022 15:09:41 +0100 (CET)<br>
From: PICCA Frederic-Emmanuel<br>
        <<a href="mailto:frederic-emmanuel.picca@synchrotron-soleil.fr" target="_blank">frederic-emmanuel.picca@synchrotron-soleil.fr</a>><br>
To: <a href="mailto:haskell-cafe@haskell.org" target="_blank">haskell-cafe@haskell.org</a><br>
Subject: [Haskell-cafe] optparse-applicative with attoparsec parser<br>
Message-ID:<br>
        <<a href="mailto:30404406.15581346.1643983781075.JavaMail.zimbra@synchrotron-soleil.fr" target="_blank">30404406.15581346.1643983781075.JavaMail.zimbra@synchrotron-soleil.fr</a>><br>
<br>
Content-Type: text/plain; charset=utf-8<br>
<br>
Hello,<br>
<br>
I Try to write a parser for this command line<br>
<br>
binoculars-ng --debug process data/test/config_sixs_ruche_flymedv_3.ini 698-734 735-736<br>
<br>
But I  have this problem<br>
<br>
Invalid argument `735-736'<br>
<br>
The parser used for this is this one<br>
<br>
processOptions :: Parser Options<br>
processOptions = Process<br>
                 <$> optional config<br>
                 <*> optional (argument (eitherReader (parseOnly configRangeP . pack)) (metavar "RANGE"))<br>
<br>
it use the configRangeP attoparser parser whcih knows how to deal with the string "698-734 735-736"<br>
<br>
configRangeP :: Parser ConfigRange<br>
configRangeP = ConfigRange <$> (inputRangeP `sepBy` many (satisfy isSep))<br>
    where<br>
      isSep :: Char -> Bool<br>
      isSep c = c == ' ' || c == ','<br>
<br>
the result should be this one<br>
<br>
Just (ConfigRange [InputRangeFromTo 698 734,InputRangeFromTo 735 736])<br>
<br>
so my question how should I fix my processOptions fucntion in order to deal with this problem.<br>
<br>
thanks for considering<br></blockquote><div><br></div><div>It seems that the issue stems from having your arguments separated by spaces. If your parser is parsing [[ [debug-flag] <command> <file> <ranges> ]], then it does not know what to do with the last particle (735-736). You would need to wrap your ranges in quotes in your shell, to include the space, or replace the space with a comma instead (698-734,735-736)<br><br>Sébastien</div></div></div>