Skip to content

Releases: rushfive/RunInfoBuilder

Major Update to v2.0.0

21 Jan 02:50
Compare
Choose a tag to compare

This release brings several enhancements and features that allow for building a better and more reasonable API.

Global Options

The root Command<TRunInfo> now has a new GlobalOptions property that allow you to configure Options that are accessible to that Command and any of its SubCommands. This allows you to configure an Option that should be available for the Command or its SubCommands only once. The behavior of Options and general Command processing has not changed, and the Command or SubCommand specific options are still locally scoped to where it's declared.

builder.Commands.Add(new Command<TRunInfo>
{
    Key = "command_key",
    // other properties like Arguments and Options omited for brevity
    GlobalOptions =
    {
        // add any number of global options here
    },
    OnMatched = runInfo => 
    {
        // do something with runInfo
        return ProcessResult.Continue;
    }
});

OnMatched Callback for Commands

Commands, SubCommands, and the DefaultCommand now have a new OnMatched property, which is of type Func<TRunInfo, ProcessStageResult>. This provides a hook for you to provide a custom callback that is immediately fired when a command is matched and begins processing.

Refer to the Command configuration above this section to see how it's set.

OnParseErrorUseMessage

In several places where the Parser is used, you can now provide a callback that accepts the raw program argument and returns a customized error message to include as the exception's message.

The 3 types they're currently available in are PropertyArgument, SequenceArgument, and Option.

HelpManager's InvokeOnBuildFail

Method was previously named DisplayOnBuildFail. It also now requires a new bool argument named suppressException, allowing you to decide whether to suppress exceptions or not. Previously, if the help menu was set to auto invoke on build fail, the exception would be suppressed, with no option to do otherwise.

New ArgsNullOrEmptyReturns Hook

A new method was added to the builder's Hooks. You can now provide a Func<TReturn> that will be invoked if the program arguments is either null or empty. The builder will then return whatever is returned by that custom function.

Initial Release

25 Oct 20:56
Compare
Choose a tag to compare

Initial release of the library.

Core features included:

  • program arguments parsing
  • parser
  • help menu
  • version