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
-
Note: Changes are backward compatible for standard usage scenarios (i.e. using
ECFHostBuilder
andCommandBase
classes).1. Linux users, I've got something for you
system32.CommandLineToArgW
was rewritten to fully support Linux builds2. ECF is now fully asynchronous
AsyncCommandBase
, which allow to utilize async behaviourCancellationToken
for graceful interruptionCommandBase
is now wrappingAsyncCommandBase
to reflect old behaviorICommand
has new interfaceExecute
changed toTask ExecuteAsync(CommandArguments args, CancellationToken cancellationToken)
ApplyArguments
has been removed (it is still used internally insideAsyncCommandBase
)CancellationToken
need to be handled for graceful interruption, for generic use I recommend puttingcancellationToken.Register(() => Environment.Exit(1))
CTRL
+C
now tries to interrupt current command instead of interrupting whole programICommand
andAsyncCommandBase
token will be cancelled. If token is not handled, command will run despite cancel signal.CommandBase
this will invokeEnvironment.Exit(1)
CTRL
+C
twice 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)DefaultCommand
option inInterfaceContext
(not necessary when usingUseSingleCommand
)program.exe hello john
will first check if commandhello
exits and tries to invoke it with args["john"]
, if there is no such command it will invoke default command with args["hello", "john"]
CommandArguments
now have new propertyExecutedAsDefaultCommand
which will indicate if command was invoked via fallback mechanism: when no arguments were passed or when command name was not found by matching first argumentDisablePrompting
insideInterfaceContext
(true
when usingUseSingleCommand
), which will invoke default command, instead of prompt mode, when program started without argumentsNotFoundCommand
was merged intoHelpCommand
, it now utilizeExecutedAsDefaultCommand
to whenever displaycommand not found
or notUseDefaultCommands()
now setsHelpCommand
as 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
CommandBase
andAsyncCommandBase
will react to-h
and--help
with displaying help message (same ashelp commandname
)5. Other changes
RequiredAttribute
to 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]
ECFException
which can help you managing exception better in your applicationInterfaceContext
now 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)AddECFCommandRegistry
now uses configure Action inside extension method to register commandsICommandProcessor
looks like this:This discussion was created from the release ECF v1.0.1 - Async commands, DevOps tasks and more.
Beta Was this translation helpful? Give feedback.
All reactions