darcs

Patch 1984 finally fix parsing of option arguments (and 2 more)

Title finally fix parsing of option arguments (and 2 more)
Superseder Nosy List bfrk
Related Issues
Status accepted Assigned To
Milestone

Created on 2020-02-11.08:33:42 by bfrk, last changed 2020-07-19.15:41:57 by bfrk.

Files
File name Status Uploaded Type Edit Remove
finally-fix-parsing-of-option-arguments.dpatch bfrk, 2020-02-11.08:33:42 application/x-darcs-patch
fix-extraneous-space-in-error-message.dpatch bfrk, 2020-02-11.09:40:53 application/x-darcs-patch
patch-preview.txt bfrk, 2020-02-11.08:33:42 text/x-darcs-patch
patch-preview.txt bfrk, 2020-02-11.09:40:53 text/x-darcs-patch
unnamed bfrk, 2020-02-11.08:33:42 text/plain
unnamed bfrk, 2020-02-11.09:40:53 text/plain
See mailing list archives for discussion on individual patches.
Messages
msg21789 (view) Author: bfrk Date: 2020-02-11.08:33:42
This has been bugging me for a looong time.

The fix is pragmatic. Refactoring the option system to allow for failure
when parsing the command line flags would have been more principled but
/much/ more difficult and invasive. It is a good thing that we can now
produce clean failures by throwing a dedicated exception type (in contrast
to calling error which will "crash" darcs with a "This is a bug, please
report it" message).

3 patches for repository http://darcs.net/screened:

patch 262290797f77f252eda1d409ef2be56ba939d51b
Author: Ben Franksen <ben.franksen@online.de>
Date:   Mon Feb 10 20:56:29 CET 2020
  * finally fix parsing of option arguments
  
  This concerns --index=, --max-count, and --last. Parsing the argument as an
  integer or a range of integers may fail, as well as limiting the value to a
  range (counts should be >= 0, an index should be > 0). This was previously
  either not handled or in an unreliable way via in-band values. Since back
  when I re-designed the option system I failed to allow for failure, we now
  throw a special exception type, so we'll get a clean failure with a message.

patch 9943041892a3525695e3f337a6bc5e99485814dd
Author: Ben Franksen <ben.franksen@online.de>
Date:   Mon Feb 10 20:57:26 CET 2020
  * fix some outdated TODO items in D.UI.Options.All

patch 7a959afdea9148d08dde6521d908e7b5f093f989
Author: Ben Franksen <ben.franksen@online.de>
Date:   Mon Feb 10 21:16:32 CET 2020
  * improve haddocks in D.UI.Options.Util
Attachments
msg21790 (view) Author: bfrk Date: 2020-02-11.09:40:53
Following up with tests and a small typo fix.

3 patches for repository http://darcs.net/screened:

patch dce961afad755bdc6dc8f29e186b59c5d66b6a28
Author: Ben Franksen <ben.franksen@online.de>
Date:   Tue Feb 11 10:35:11 CET 2020
  * fix extraneous space in error message

patch e3ba81f30e65ebcbdc98e73bdd9d748103cde28e
Author: Ben Franksen <ben.franksen@online.de>
Date:   Sun Feb  9 20:42:15 CET 2020
  * add test for log --index=N-M

patch de67dc945ddb94b50727ab2ed26d21ed1300016e
Author: Ben Franksen <ben.franksen@online.de>
Date:   Tue Feb 11 10:52:21 CET 2020
  * add test for clean failure with malformed option arguments
Attachments
msg22175 (view) Author: ganesh Date: 2020-07-18.22:58:14
On 11/02/2020 08:33, Ben Franksen wrote:

>   * finally fix parsing of option arguments

Looks good. I think it'd have been slightly nicer to have had
showIntArg/showIndexRangeArg counterparts to
parseIntArg/prettyIndexRangeArg in D.UI.Options.Utils so that the string
formats are defined in one place, but it's no big deal.

>   * fix some outdated TODO items in D.UI.Options.All
>   * improve haddocks in D.UI.Options.Util
>   * fix extraneous space in error message
>   * add test for log --index=N-M
>   * add test for clean failure with malformed option arguments

All fine.
msg22197 (view) Author: bfrk Date: 2020-07-19.15:41:56
>>   * finally fix parsing of option arguments
> 
> Looks good. I think it'd have been slightly nicer to have had
> showIntArg/showIndexRangeArg counterparts to
> parseIntArg/prettyIndexRangeArg in D.UI.Options.Utils so that the string
> formats are defined in one place, but it's no big deal.

Good idea. See patch2058.
History
Date User Action Args
2020-02-11 08:33:42bfrkcreate
2020-02-11 08:34:58bfrksetstatus: needs-screening -> needs-review
2020-02-11 09:40:53bfrksetfiles: + patch-preview.txt, fix-extraneous-space-in-error-message.dpatch, unnamed
messages: + msg21790
2020-07-18 22:58:06ganeshsetstatus: needs-review -> accepted-pending-tests
2020-07-18 22:58:15ganeshsetmessages: + msg22175
2020-07-19 09:04:56ganeshsetstatus: accepted-pending-tests -> accepted
2020-07-19 15:41:57bfrksetmessages: + msg22197