Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language-specific CLI options #27

Open
thinker227 opened this issue Oct 25, 2022 · 0 comments
Open

Language-specific CLI options #27

thinker227 opened this issue Oct 25, 2022 · 0 comments
Labels
frontend The CLI interface or other user-facing issues language Feature relating to input or output languages

Comments

@thinker227
Copy link
Owner

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.

@thinker227 thinker227 added frontend The CLI interface or other user-facing issues language Feature relating to input or output languages labels Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend The CLI interface or other user-facing issues language Feature relating to input or output languages
Projects
None yet
Development

No branches or pull requests

1 participant