Factor out and export defaultCommands #959
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This reduces the amount of copy-pasting required to add custom sub-commands to the hakyll cli.
For my personal hakyll-created website, I implemented a
myHakyll
function that uses a custommyOptionsParser
andmyCommandParser
to allow for custom command line options and commands:While I want to add some custom commands, I also would like to keep all the base commands provided by
hakyll
. With the currenthakyll
v4.15.1.1 I had to copy-paste the command definitions fromHakyll.Main.commandParser
for my ownmyCommandParser
to achieve this. (See this commit for the full implementation)With the addition of
defaultCommands
to the public interface ofhakyll
this copying and pasting is no longer necessary. Now I can importdefaultCommands
andfmap HakyllCommand
over the second component (Parser Command
) of the command tuples returned bydefaultCommands
and add my custom commands to the end. (See commit: Remove copy pasted code from hakyll for an example)Additionally, this removes the need to manually keep the copy-pasted list of commands up to date with the current
hakyll
version whenever an update is applied, as we now get the latest set of commands fromhakyll
automatically.It would be awesome if this could be added to the public API. I'm happy to keep working on this if any changes are required before a merge is possible. Let me know what you think.
Kind regards,
Alexander Pankoff