dotnet / command-line-api

Command line parsing, invocation, and rendering of terminal output.
https://github.com/dotnet/command-line-api/wiki
MIT License
3.38k stars 381 forks source link

HostingAction for options handlers #2352

Open derigel23 opened 6 months ago

derigel23 commented 6 months ago

Currently System.CommandLine.Hosting.HostingExtensions.UseHost set HostingAction wrapper for command and its subcommands actions. But, options can have also own actions and they are not wrapped with HostingAction

elgonzo commented 6 months ago

To my knowledge, Options in System.CommandLine do not feature actions. Actions (or handlers, as they were called in older System.CommandLine versions) are features of commands. Could you please clarify what exactly you mean by saying "options can have also own actions"?

(Side note: In case you aren't already aware, please consider reading this announcement: https://github.com/dotnet/command-line-api/issues/2338 and issue threads following this announcement.)

KalleOlaviNiemitalo commented 6 months ago

@elgonzo, there's the CliOption.Action property. It was added in https://github.com/dotnet/command-line-api/pull/2095 as Option.Action, largely intended for --help and --version.

elgonzo commented 6 months ago

@KalleOlaviNiemitalo thanks for the clarification!