Skip to content
This repository has been archived by the owner on Mar 1, 2021. It is now read-only.

Commit

Permalink
Merge pull request #27 from adamralph/target-dictionary
Browse files Browse the repository at this point in the history
Optional TargetDictionary
  • Loading branch information
adamralph committed Oct 16, 2016
2 parents c711270 + 0fed408 commit 9e8197e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
12 changes: 12 additions & 0 deletions src/simple-targets-csharp.csx
Expand Up @@ -33,4 +33,16 @@ public static class SimpleTargets

public Action Action { get; }
}

public class TargetDictionary : Dictionary<string, Target>
{
public void Add(string name, IEnumerable<string> dependencies, Action action) =>
this.Add(name, new Target(dependencies, action));

public void Add(string name, IEnumerable<string> dependencies) =>
this.Add(name, new Target(dependencies, null));

public void Add(string name, Action action) =>
this.Add(name, new Target(null, action));
}
}
4 changes: 2 additions & 2 deletions tests/quickstart.csx
Expand Up @@ -2,8 +2,8 @@

using static SimpleTargets;

var targets = new Dictionary<string, Target>();
var targets = new TargetDictionary();

targets.Add("default", new Target(() => Console.WriteLine("Hello, world!")));
targets.Add("default", () => Console.WriteLine("Hello, world!"));

Run(Args, targets);
10 changes: 5 additions & 5 deletions tests/test.csx
Expand Up @@ -2,14 +2,14 @@

using static SimpleTargets;

var targets = new Dictionary<string, Target>();
var targets = new TargetDictionary();

targets.Add("default", new Target(DependsOn("world", "exclaim")));
targets.Add("default", DependsOn("world", "exclaim"));

targets.Add("hello", new Target(() => Console.WriteLine("Hello, ")));
targets.Add("hello", () => Console.WriteLine("Hello, "));

targets.Add("world", new Target(DependsOn("hello"), () => Console.WriteLine("World")));
targets.Add("world", DependsOn("hello"), () => Console.WriteLine("World"));

targets.Add("exclaim", new Target(() => Console.WriteLine("!")));
targets.Add("exclaim", () => Console.WriteLine("!"));

Run(Args, targets);

0 comments on commit 9e8197e

Please sign in to comment.