I'm developing a .net tool for building our projects. I'm using System.CommandLine package for collect command line argument without sweat. My build command looks like this:
[Command(Description = "Runs build process")]
public class Build
{
public int Execute(
[Option] string targetDirectory,
[Option(Aliases = new[] {"-c"})] string configuration = "Release")
{
return new CakeHost()
.UseContext<BuildContext>()
.Run(Enumerable.Empty<string>());
}
}
Note that there are attributes not available in the Microsoft's library. It's my addition. Type is converted into Command
on the fly.
The important thing is that Cake
takes arguments only as string collection. So the only way I can see here, is to convert arguments into strings and parse it again inside a task. I will not able to sleep for a month if I do that.
The solution I would expect here is to create and pass an instance of BuildContext
type (it inherits from FrostingContext
). I could simply have properties corresponding to app arguments.
Any ideas how to workaround it? Or maybe there is a feature I don't know?