48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using ln.build.commands;
|
|
|
|
namespace ln.build.pipeline
|
|
{
|
|
public abstract class StageCommand
|
|
{
|
|
public string Name { get; }
|
|
|
|
public StageCommand(string name)
|
|
{
|
|
Name = name;
|
|
}
|
|
|
|
public abstract void Run(Stage stage);
|
|
|
|
|
|
|
|
|
|
|
|
static Dictionary<string,Func<string,StageCommand>> commandFactories = new Dictionary<string, Func<string, StageCommand>>();
|
|
|
|
public static StageCommand Create(string cmdline)
|
|
{
|
|
string[] tokens = cmdline.Split(new char[]{' ','\t'}, 2);
|
|
|
|
if (commandFactories.TryGetValue(tokens[0],out Func<string,StageCommand> factory))
|
|
{
|
|
return factory(tokens[1]);
|
|
}
|
|
throw new Exception(string.Format("can't find factory for command keyword '{0}'", tokens[0]));
|
|
}
|
|
|
|
static StageCommand()
|
|
{
|
|
commandFactories.Add("SH", (args) => new ShellCommand(args));
|
|
commandFactories.Add("DOTNET", (args) => new DotNetCommand(args));
|
|
commandFactories.Add("GITEA", (args) => new DotNetCommand(args));
|
|
commandFactories.Add("RELEASE", (args) => new ReleaseCommand(args));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} |