ECF v1.0.1 - Async commands, DevOps tasks and more #9
Aviuz
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Note: Changes are backward compatible for standard usage scenarios (i.e. using
ECFHostBuilderandCommandBaseclasses).1. Linux users, I've got something for you
system32.CommandLineToArgWwas rewritten to fully support Linux builds2. ECF is now fully asynchronous
AsyncCommandBase, which allow to utilize async behaviourCancellationTokenfor graceful interruptionCommandBaseis now wrappingAsyncCommandBaseto reflect old behaviorICommandhas new interfaceExecutechanged toTask ExecuteAsync(CommandArguments args, CancellationToken cancellationToken)ApplyArgumentshas been removed (it is still used internally insideAsyncCommandBase)CancellationTokenneed to be handled for graceful interruption, for generic use I recommend puttingcancellationToken.Register(() => Environment.Exit(1))CTRL+Cnow tries to interrupt current command instead of interrupting whole programICommandandAsyncCommandBasetoken will be cancelled. If token is not handled, command will run despite cancel signal.CommandBasethis will invokeEnvironment.Exit(1)CTRL+Ctwice will result in callingEnvironment.Exit(1)in any scenarioLoadScriptCommand, along withScriptLoader.3. Now ECF is more suitable for DevOps tasks with arrival of Default Commands
ECFHostBuilder.UseSingleCommand<TCommand>(), which will enforce program to run only command you've specified (default command + no prompt mode + no commands in registry)DefaultCommandoption inInterfaceContext(not necessary when usingUseSingleCommand)program.exe hello johnwill first check if commandhelloexits and tries to invoke it with args["john"], if there is no such command it will invoke default command with args["hello", "john"]CommandArgumentsnow have new propertyExecutedAsDefaultCommandwhich will indicate if command was invoked via fallback mechanism: when no arguments were passed or when command name was not found by matching first argumentDisablePromptinginsideInterfaceContext(truewhen usingUseSingleCommand), which will invoke default command, instead of prompt mode, when program started without argumentsNotFoundCommandwas merged intoHelpCommand, it now utilizeExecutedAsDefaultCommandto whenever displaycommand not foundor notUseDefaultCommands()now setsHelpCommandas default command (if not set already)UseDefaultCommands()and you want to restore old NotFoundCommand behavior please setctx.DefaultCommand = typeof(ECF.BaseKitCommands.HelpCommand)in your.Configure((ctx, services, _) =>section4. Help is now more helpful
CommandBaseandAsyncCommandBasewill react to-hand--helpwith displaying help message (same ashelp commandname)5. Other changes
RequiredAttributeto use with[Argument]/[Parameter]/[Flag], which will prevent command from running if not set by user (CommandBase,AsyncCommandBase)CommandBase,AsyncCommandBase|[Argument],[Parameter],[Flag])StringComparison, defaults toStringComparison.InvariantCulture(CommandBase,AsyncCommandBase|[Argument],[Parameter],[Flag])[Flag]s and[Paremeter]s[Flag(ShortName="f", LongName="flag")]=>[Flag("-f --flag")]/[Flag("-f", "--flag")]~~tilde-flag)CommandBase,AsyncCommandBase|[Argument],[Parameter])-will be ignoredForbiddenValuePrefixes = new string[0]ECFExceptionwhich can help you managing exception better in your applicationInterfaceContextnow does not include space after, which can be added to maintain old behavior. (Marking this as breaking change because it can break some automated tests)AddECFCommandRegistrynow uses configure Action inside extension method to register commandsICommandProcessorlooks like this:This discussion was created from the release ECF v1.0.1 - Async commands, DevOps tasks and more.
All reactions