Skip to content

Changing Things when Things need a changin'

Compare
Choose a tag to compare
@istathar istathar released this 13 Feb 01:03
· 89 commits to main since this release

Changing Program

The original design of core-program's configure function had you specifying the initial value of the top-level application state τ. This has proved to be unwieldly, as it seems we all want to do things like querying the options and arguments in order to compose that starting value.

A number of us simultaneously his the same question, and independently came up with the same solution: enable the developer to change their Program τ to Program υ , where υ is the new top-level application state type. The new function enabling this is changeProgram. This means you can start your program in Program None and then switch to Program Settings or Program This,That, or TheOtherThing once you've worked out which way you're going (this latter example has emerged as a way to give each different command in your program its own top-level type. Interesting!). Thanks to @guaraqe and @dmvianna for validating this use case and approving the implementation!

  • Enable changing application state type in sub programs by @istathar in #168

Changing Process

Some internal surgery and re-arranging allows us to introduce execProcess_, a function which will result in an exec(2) system call to replace your running program with a new one. It's important to use this helper function (rather than calling the Posix functions in unix directly) so that you can be confident that output logging and telemetry have been sent before switching to the the new binary.

  • Invoke (and replace with) external processes by @istathar in #169

While the trailing underscore convention is appropriate here, the function previously named execProcess used for running a child and reading its output was misplaced, and so we've renamed it to readProcess. Not sure what we were thinking there, but the underlying name from upstream is clearly better and so we return to presenting our wrapper in the same style.

Bug fixes and general improvements

Introduce a new pair of functions for constructing Configs that allow adding top-level precis descriptions for --help output, simpleConfig' and complexConfig', each taking an additional parameter supplying the descriptive text to be printed above the "Usage:" section. It's just cosmetic, but we've been wanting to add this for a long time; makes for a nice touch to have a short description of the program before getting into the nitty-gritty of command-line options and arguments.

New Contributors

Full Changelog: core-program-0.6.2.2...core-program-0.6.5.0