Bump to 2.0.0.0, Append changelog, Update readme
parent
5486bf0737
commit
4f169af01c
33
ChangeLog.md
33
ChangeLog.md
|
@ -1,5 +1,38 @@
|
||||||
# Revision history for butcher
|
# Revision history for butcher
|
||||||
|
|
||||||
|
## 2.0.0.0 -- Sept 2020
|
||||||
|
|
||||||
|
Large internal refactor including some breaking API changes.
|
||||||
|
|
||||||
|
- Add the "Applicative" interface in addition to the existing "Monadic" one.
|
||||||
|
This is slightly less expressive but conceptually cleaner/safer (and its
|
||||||
|
implementation is nicer). For best readability you may need `ApplicativeDo`.
|
||||||
|
- The applicative interface is *NOT* finished and the test-suite does not
|
||||||
|
cover it.
|
||||||
|
- Add the `traverseBarbie` construct to elegantly define a parser for a
|
||||||
|
config data-structure.\
|
||||||
|
Introduces a dependency on the `barbies` library.
|
||||||
|
- 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`.
|
||||||
|
- Remove deprecated functions
|
||||||
|
- `peekCmdDesc` is now guaranteed to yield the proper full `CmdDesc` value
|
||||||
|
for the current command or child-command.
|
||||||
|
- Remove the `mainFromCmdParserWithHelpDesc` function, because it is redundant
|
||||||
|
given the new semantics of `peekCmdDesc`.
|
||||||
|
- Stop support for an anti-feature: The implicit merging of multiple
|
||||||
|
sub-commands definitions with the same name.
|
||||||
|
- Internal refactor: The 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
|
||||||
|
|
||||||
## 1.3.3.2 -- June 2020
|
## 1.3.3.2 -- June 2020
|
||||||
|
|
||||||
* Support ghc-8.10
|
* Support ghc-8.10
|
||||||
|
|
39
README.md
39
README.md
|
@ -9,19 +9,24 @@ The main differences are:
|
||||||
|
|
||||||
* Provides a pure interface by default
|
* Provides a pure interface by default
|
||||||
|
|
||||||
* Exposes an evil monadic interface, which allows for much nicer binding of
|
* Exposes two interfaces: One based on `Applicative` and one based on `Monad`.
|
||||||
command part results to some variable name.
|
The monadic one is slightly more expressive, the applicative interface is
|
||||||
|
conceptually cleaner but currently is less tested.
|
||||||
|
|
||||||
In `optparse-applicative` you easily lose track of what field you are
|
* The monadic interface must be used as if `ApplicativeDo` was enabled,
|
||||||
modifying after the 5th `<*>` (admittedly, i think -XRecordWildCards
|
but does not actually require `ApplicativeDo`. This is implemented via
|
||||||
improves on that issue already.)
|
some evil hackery, but nonetheless useful.
|
||||||
|
|
||||||
Evil, because you are not allowed to use the monad's full power in this
|
* It is not necessary to define data-structure for diffenent child-commands.
|
||||||
case, i.e. there is a constraint that is not statically enforced.
|
In general this is geared towards keeping names and definitions/parsers
|
||||||
See below.
|
of flags/parameters/child-commands connected, while the default
|
||||||
|
`MyFlags <$> someParser <*> … <*> … <*> … <*> … <*> …` is harder to read
|
||||||
|
and prone to accidental swapping.
|
||||||
|
|
||||||
* The monadic interface allows much clearer definitions of commandparses
|
* Supports connecting to "barbies"
|
||||||
with (nested) subcommands. No pesky sum-types are necessary.
|
(see the [`barbies`](https://hackage.haskell.org/package/barbies) package).
|
||||||
|
This allows re-using data-structure definitions for the parser and config
|
||||||
|
values without losing track of field order.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -34,7 +39,9 @@ main = mainFromCmdParser $ addCmdImpl $ putStrLn "Hello, World!"
|
||||||
But lets look at a more feature-complete example:
|
But lets look at a more feature-complete example:
|
||||||
|
|
||||||
~~~~.hs
|
~~~~.hs
|
||||||
main = mainFromCmdParserWithHelpDesc $ \helpDesc -> do
|
main = mainFromCmdParser $ do
|
||||||
|
|
||||||
|
helpDesc <- peekCmdDesc
|
||||||
|
|
||||||
addCmdSynopsis "a simple butcher example program"
|
addCmdSynopsis "a simple butcher example program"
|
||||||
addCmdHelpStr "a very long help document"
|
addCmdHelpStr "a very long help document"
|
||||||
|
@ -44,14 +51,14 @@ main = mainFromCmdParserWithHelpDesc $ \helpDesc -> do
|
||||||
(flagHelpStr "print nothing but the numeric version")
|
(flagHelpStr "print nothing but the numeric version")
|
||||||
addCmdHelpStr "prints the version of this program"
|
addCmdHelpStr "prints the version of this program"
|
||||||
addCmdImpl $ putStrLn $ if porcelain
|
addCmdImpl $ putStrLn $ if porcelain
|
||||||
then "0.0.0.999"
|
then "1.0"
|
||||||
else "example, version 0.0.0.999"
|
else "example, version 1.0"
|
||||||
|
|
||||||
addCmd "help" $ addCmdImpl $ print $ ppHelpShallow helpDesc
|
addCmd "help" $ addCmdImpl $ print $ ppHelpShallow helpDesc
|
||||||
|
|
||||||
short <- addSimpleBoolFlag "" ["short"]
|
short <- addSimpleBoolFlag "" ["short"]
|
||||||
(flagHelpStr "make the greeting short")
|
(flagHelpStr "make the greeting short")
|
||||||
name <- addStringParam "NAME"
|
name <- addParamString "NAME"
|
||||||
(paramHelpStr "your name, so you can be greeted properly")
|
(paramHelpStr "your name, so you can be greeted properly")
|
||||||
|
|
||||||
addCmdImpl $ do
|
addCmdImpl $ do
|
||||||
|
@ -62,9 +69,7 @@ main = mainFromCmdParserWithHelpDesc $ \helpDesc -> do
|
||||||
|
|
||||||
Further:
|
Further:
|
||||||
|
|
||||||
- [Full description of the above example, including sample behaviour](example1.md)
|
- See the examples folder included in the package
|
||||||
- [Example of a pure usage of a CmdParser](example2.md)
|
|
||||||
- [Example of using a CmdParser on interactive input](example3.md)
|
|
||||||
- The [brittany](https://github.com/lspitzner/brittany) formatting tool is a
|
- The [brittany](https://github.com/lspitzner/brittany) formatting tool is a
|
||||||
program that uses butcher for implementing its commandline interface. See
|
program that uses butcher for implementing its commandline interface. See
|
||||||
its [main module source](https://github.com/lspitzner/brittany/blob/master/src-brittany/Main.hs)
|
its [main module source](https://github.com/lspitzner/brittany/blob/master/src-brittany/Main.hs)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
cabal-version: 2.2
|
cabal-version: 2.2
|
||||||
name: butcher
|
name: butcher
|
||||||
version: 1.3.3.2
|
version: 2.0.0.0
|
||||||
synopsis: Chops a command or program invocation into digestable pieces.
|
synopsis: Chops a command or program invocation into digestable pieces.
|
||||||
description: See the <https://github.com/lspitzner/butcher/blob/master/README.md README> (it is properly formatted on github).
|
description: See the <https://github.com/lspitzner/butcher/blob/master/README.md README> (it is properly formatted on github).
|
||||||
license: BSD-3-Clause
|
license: BSD-3-Clause
|
||||||
|
|
Loading…
Reference in New Issue