using Progmasoft.Tazel.PluginApi;
using Progmasoft.Tazel.PluginApi.Steps;
namespace PluginProject;
/// The plugin: Tazel creates it and applies it before the BUILD.csx files of a module run.
public sealed class Plugin : ITazelPlugin
{
///
public void Apply(IPluginContext context)
{
// BUILD.csx files see PluginProject.Greetings without a using.
context.Import("PluginProject");
}
}
/// What BUILD.csx files of a module with this plugin can write: Greetings.File("hello", "Hello!").
public static class Greetings
{
/// A step that writes to greeting.txt in its output directory.
public static Progmasoft.Tazel.Dsl.Common.Target File(string name, string text) =>
Step.Declare(name, new()
{
Outputs = ["greeting.txt"],
Key = text,
Run = async (step, cancel) =>
await System.IO.File.WriteAllTextAsync(Path.Combine(step.OutputDirectory, "greeting.txt"), text + "\n", cancel),
});
}