Commit Graph

53 Commits (91d57b07c4714086eb482cb15abf389eb2f000d5)

Author SHA1 Message Date
Lennart Spitzner 91d57b07c4 Clean up haddocks 2022-12-14 15:02:47 +01:00
Lennart Spitzner 5d67167c87 Major changeset: Add applicative, Refactor monadic interface
- monadic interface now uses two-phase setup: First step is to create a
  full CommandDesc value, second is running the parser on input while the
  CommandDesc is chained along
- applicative interface has a somewhat nicer/cleaner implementation, is
  more secure by avoiding any demands on the API user that are not encoded
  in types, but is slightly less expressive and requires ApplicativeDo to
  get readable code.
- The applicative interface is *NOT* finished and the test-suite does not
  cover it.
- Add the `traverseBarbie` construct which introduces a dependency on
  the `barbies` library. This also effectively:
- Stop support for ghc < 8.4.
- Refactor the module structure a bit, and change the API of the central
  `runCmdParser` function. It now returns a `PartialParseInfo`. Essentially,
  `runCmdParser` is a combination of the previous `runCmdParser` and the
  previous `simpleCompletion`. This API design is a curious advantage to
  laziness: Returning a complex struct is harmless as fields that the user
  does not use won't be evaluated. The downside is that the core function now
  looks like a complex beast, but the upside is that there is no need to
  expose multiple functions that are supposed to be chained in a certain way
  to get all functionality (if desired), and we still _can_ provide simpler
  versions that are just projections on the `PartialParseInfo`.
- Stop support for an anti-feature: The implicit merging of multiple
  sub-commands definitions with the same name.
2022-12-14 15:02:47 +01:00
Lennart Spitzner c23c53fe25 Fix another duplicated desc bug 2020-06-10 12:18:06 +02:00
Lennart Spitzner c29ef0cce2 Fix duplicated desc-parts bug 2020-06-09 17:18:27 +02:00
Lennart Spitzner bb646321fe Add the descendDescTo function, minor formatting 2020-04-10 23:40:21 +02:00
Lennart Spitzner 34d94c2d2e Fix buggy handling of defaults on CmdParserPart 2020-04-10 23:34:26 +02:00
Lennart Spitzner ded3192962 Simplify/Clean up prelude.inc 2020-04-10 23:31:47 +02:00
Lennart Spitzner 593d903a53 Fix too-shallow descs for "siblings" 2018-12-02 14:08:09 +01:00
Lennart Spitzner 516b975ac7 Switch to latest deque version 2018-10-07 16:05:38 +02:00
Lennart Spitzner c16eefdb0e Fix some -Wcompat issues (MFP) 2018-10-03 22:08:09 +02:00
Lennart Spitzner 8b12f38d6b Expose things properly (missing re-exports) 2018-10-03 22:06:17 +02:00
Lennart Spitzner 131216d4f4 Fix bug in simpleCompletion 2018-10-03 22:06:17 +02:00
Lennart Spitzner 7d56c9ae1d Add addAlternatives, Add/Expose varPartDesc 2018-04-17 18:11:41 +02:00
Lennart Spitzner e0dd252707 Adapt to ghc-8.4, Drop support for ghc<8 2018-04-13 20:47:08 +02:00
Lennart Spitzner 0313b0d68d Improve completion behaviour 2018-02-12 15:47:27 +01:00
Lennart Spitzner a495e13e53 Add addHelpCommandWith; Improve layouting for help/docs 2018-01-12 23:16:20 +01:00
Lennart Spitzner 9337ab8d40 Switch to using newlines as separator between completions 2018-01-12 00:08:26 +01:00
Lennart Spitzner 327f596d1d Add bash-completion support (experimental) 2018-01-11 21:47:49 +01:00
Lennart Spitzner a4e80cc8fc Add addHelpCommand2 making use of the new ppHelpDepthOne 2018-01-10 22:49:18 +01:00
Lennart Spitzner e1c38e430f Support hiding flags 2018-01-10 22:39:40 +01:00
Lennart Spitzner 92a7339590 Add functions ppUsageShortSub and ppHelpDepthOne 2018-01-10 22:00:55 +01:00
Lennart Spitzner 548f2ccd8f Apply autoformatting and Refactor slightly 2018-01-10 00:53:51 +01:00
Lennart Spitzner 0f5aa00bb3 Support hiding commands (and parts, in theory) 2018-01-10 00:32:08 +01:00
Lennart Spitzner bedc74462b Fix addHelpCommand to not expect a local CommandDesc 2018-01-09 16:30:37 +01:00
Lennart Spitzner d9b56af676 Add interactive utils in new module 'Monadic.Interactive' 2017-11-13 21:27:58 +01:00
Lennart Spitzner c4f930f3db Fix bug in `ppUsageWithHelp` and some mistakes in docs 2017-11-13 21:18:09 +01:00
Lennart Spitzner b2a25f3a07 Rename param functions, Add `addParamNoFlagString*`, Fix flag behaviour 2017-10-03 17:06:15 +02:00
Lennart Spitzner 95886b898b Add `addNullCmd` and `addStringParams` 2017-10-02 22:45:43 +02:00
Lennart Spitzner 12a2bed6c8 Improve usage pretty-printing: children in separate line 2017-08-10 18:03:07 +02:00
Lennart Spitzner 9433991ae6 Improve usage pretty-printing a bit more 2017-08-10 17:56:41 +02:00
Lennart Spitzner 0be78a3aab Fix usage pretty-printing block output 2017-08-10 17:49:31 +02:00
Lennart Spitzner 97f7165656 Fix two bugs
- when input was missing inside a reorder, butcher
  erroneously reported an monadMisuseError;
- flags that allow multiple occurences/values returned
  the results in the reversed order.
2017-05-16 23:44:54 +02:00
Lennart Spitzner 719d447701 Add function parsingErrorString 2017-05-16 22:03:25 +02:00
Lennart Spitzner 8793adcc7d Add function runCmdParserSimple 2017-05-16 21:50:47 +02:00
Lennart Spitzner 12b886ad31 Allow --flag=value syntax in addition to --flag value 2017-05-16 21:02:01 +02:00
Lennart Spitzner 6a45f4b3a6 Add withReorder function 2017-05-16 13:28:32 +02:00
Lennart Spitzner 6a4d15e895 Add more haddock 2017-05-16 13:20:28 +02:00
Lennart Spitzner c1cbc77e5b Implement mapOut, peekInput, cmd child merging 2017-05-16 12:22:28 +02:00
Lennart Spitzner b15f1ae585 Refactor module structure; Add haddock; Update README 2017-01-01 14:46:53 +01:00
Lennart Spitzner aecef373f9 Add ppUsageWithHelp 2016-12-30 22:16:04 +01:00
Lennart Spitzner 76e3baad76 Make help print subcommand help as well (addHelpCommand) 2016-12-30 22:16:04 +01:00
Lennart Spitzner 046812cecb Add addRestOfInputStringParam 2016-12-30 22:16:04 +01:00
Lennart Spitzner 11db0a98ab Fix InputString parsing for addFlagStringParam function family 2016-12-30 22:16:04 +01:00
Lennart Spitzner f35ebb733a Fix/Implement knot-tying of the CommandDesc cyclic graph structure 2016-12-30 22:16:03 +01:00
Lennart Spitzner b11663d910 Add 'suggestion' functionality
i.e. possible additional input that could make the input valid
(or at least less invalid).
2016-12-30 22:16:03 +01:00
Lennart Spitzner a3ff58c682 Allow returning remaining-non-childcommand input
more specifically, the part of the input that is not part of any
successfully parsed subcommand invocation. "remaining" is not
completely accurate because this works even when all input
is processed.
2016-12-30 22:02:32 +01:00
Lennart Spitzner 04cb0bdea5 Clean up imports; Reduce dep footprint s/lens/microlens/ 2016-10-11 00:27:26 +02:00
Lennart Spitzner 37fa57dfc2 Create `addFlagFooParam` variants matching exactly once (breaking change)
- addFlagReadParams was previously named addFlagReadParam, similarly
  addFlagStringParams/addFlagStringParam.
- The "singular" variants have semantics that did not exist before:
  to match exactly once and thus having type `CmdParser f out p` instead
  of `CmdParser f out [p]`.
2016-09-29 21:31:27 +02:00
Lennart Spitzner e0885a4f48 Add addStringParam, addStringParamOpt 2016-09-06 15:09:46 +02:00
Lennart Spitzner a4e3d155d6 Fix: Print errors to stderr, not stdout 2016-09-04 00:50:03 +02:00