You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be useful to be able to pass options to (at least) the output language from the CLI. This would essentially act like the .NET CLI which allows for passing additional named options to the template in dotnet new <template>.
One possible API for this is to simply expose a Dictionary<string, string> to the output language which contains the additional options as key-value pairs. The upside of this approach would be that it would only require some method of parsing additional CLI options, and the output language handles everything else by itself. Another slightly more involved option would be to expose an object which internally contains the options as key-value pairs but which provides a simple parse API using something like Get<T>(string longName, string? shortName). Obvious upside of this is that the output language doesn't need to parse anything by itself.
A third much more involved option would be to require output languages to specify whether they need any options and what those options are. This would likely be done through some kind of reflection-based API using a generic variant of the IOutputLanguage interface, for instance IOutputLanguage<TOptions>. Downside of this is that it would require a much more involved API, although the obvious upside is that it would massively simplify the API for the output languages, where the languages could simply implement IOutputLanguage<TOptions> and receive the options in the EmitAsync method. This could also allow for better CLI errors since this API would allow for statically available options which means that the CLI could report an error if an invalid/misspelled option was specified. The other two approaches don't have this benefit as they would simply swallow invalid/misspelled options.
All of these options would require some degree of a custom CLI parser, or at least a CLI parser framework which can parse additional options and give them back in a meaningful way.
The text was updated successfully, but these errors were encountered:
It would be useful to be able to pass options to (at least) the output language from the CLI. This would essentially act like the .NET CLI which allows for passing additional named options to the template in
dotnet new <template>
.One possible API for this is to simply expose a
Dictionary<string, string>
to the output language which contains the additional options as key-value pairs. The upside of this approach would be that it would only require some method of parsing additional CLI options, and the output language handles everything else by itself. Another slightly more involved option would be to expose an object which internally contains the options as key-value pairs but which provides a simple parse API using something likeGet<T>(string longName, string? shortName)
. Obvious upside of this is that the output language doesn't need to parse anything by itself.A third much more involved option would be to require output languages to specify whether they need any options and what those options are. This would likely be done through some kind of reflection-based API using a generic variant of the
IOutputLanguage
interface, for instanceIOutputLanguage<TOptions>
. Downside of this is that it would require a much more involved API, although the obvious upside is that it would massively simplify the API for the output languages, where the languages could simply implementIOutputLanguage<TOptions>
and receive the options in theEmitAsync
method. This could also allow for better CLI errors since this API would allow for statically available options which means that the CLI could report an error if an invalid/misspelled option was specified. The other two approaches don't have this benefit as they would simply swallow invalid/misspelled options.All of these options would require some degree of a custom CLI parser, or at least a CLI parser framework which can parse additional options and give them back in a meaningful way.
The text was updated successfully, but these errors were encountered: