Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
09f3178
Run a dependency with the value it was declared with
Mpdreamz Nov 12, 2026
c226611
Document that a dependency runs with the value it names
Mpdreamz Nov 12, 2026
e0902b6
Draw the plan with --graph, and list the run order in target help
Mpdreamz Nov 12, 2026
b85d642
Run a command's parallel stages side by side
Mpdreamz Nov 12, 2026
3dcae3d
Add conditions, ordering, cleanup and preconditions to every target s…
Mpdreamz Nov 12, 2026
8e2e6fb
Run several targets from one command line, and leave targets out with…
Mpdreamz Nov 12, 2026
75bf1c3
Teach the package skills the new target features
Mpdreamz Nov 12, 2026
77fed67
Merge remote-tracking branch 'origin/main' into make/dependency-values
Mpdreamz Nov 12, 2026
3933be8
Merge branch 'make/run-graph' into make/parallel
Mpdreamz Nov 12, 2026
8ab8ef0
Merge branch 'make/parallel' into make/modifiers
Mpdreamz Nov 12, 2026
0f224f4
Merge branch 'make/modifiers' into make/cli
Mpdreamz Nov 12, 2026
a9681b3
Merge branch 'make/dependency-values' into make/run-graph
Mpdreamz Nov 12, 2026
ff05d77
Format with curb 0.14.1
Mpdreamz Nov 12, 2026
09465a0
Merge branch 'make/parallel' into make/modifiers
Mpdreamz Nov 12, 2026
0e3a8d6
Merge branch 'make/modifiers' into make/cli
Mpdreamz Nov 12, 2026
c233636
Merge remote-tracking branch 'origin/main' into make/run-graph
Mpdreamz Nov 12, 2026
151a6de
Merge branch 'make/run-graph' into make/parallel
Mpdreamz Nov 12, 2026
8d03e41
Merge branch 'make/parallel' into make/modifiers
Mpdreamz Nov 12, 2026
271f998
Merge branch 'make/modifiers' into make/cli
Mpdreamz Nov 12, 2026
9125590
Merge remote-tracking branch 'origin/main' into make/parallel
Mpdreamz Nov 12, 2026
de80887
Merge branch 'make/parallel' into make/modifiers
Mpdreamz Nov 12, 2026
ef2670b
Merge branch 'make/modifiers' into make/cli
Mpdreamz Nov 12, 2026
533f290
Merge remote-tracking branch 'origin/main' into make/modifiers
Mpdreamz Nov 12, 2026
7a5dbf9
Merge branch 'make/modifiers' into make/cli
Mpdreamz Nov 12, 2026
f01bf9b
Merge remote-tracking branch 'origin/main' into make/cli
Mpdreamz Nov 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/_docset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ toc:
- folder: make
children:
- file: index.md
- file: running.md
- file: graph.md
- file: parallel.md
- file: modifiers.md
Expand Down
4 changes: 4 additions & 0 deletions docs/make/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
./build.cs test --filter Unit
./build.cs release -s # skip the gates, run only the composed targets
./build.cs release --graph # draw the plan and run nothing
./build.cs lint test pack # several targets, in order, shared dependencies once
./build.cs release --skip docs
```

[**Choosing what runs**](running.md) - Several targets on one command line, `-s` and `--skip`.

[**Running targets side by side**](parallel.md) - Parallel stages, `-j`, `--keep-going`, and the output of targets
that run at once.

Expand Down
32 changes: 32 additions & 0 deletions docs/make/running.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Choosing what runs

## Several targets

A command line can name several targets. They run in the order they are named, and a dependency they share runs once:

```bash
./build.cs lint test --filter Unit pack
```

Each target takes the arguments up to the next target's name: `test` gets `--filter Unit`. A word stays with the
target before it when it is the value of an option, as in `test --filter pack`, or when that target takes positional
arguments. Everything after `--` stays with the target before it.

The `make` wrapper starts the script once per target: `make test pack` runs it twice.

## Leaving targets out

`-s` / `--single-target` skips the gates of the named target: its dependencies, or a command's requires.

`--skip <target>` leaves one target out of the plan, wherever it appears, with the dependencies that only it needed:

```bash
./build.cs release --skip docs
./build.cs release --skip "pkg validate",docs # several, separated by commas
./build.cs release --skip pkg/validate # pkg/validate and pkg:validate work too
```

`--skip` takes a target's name, not a value, so it leaves the target out whatever value it would run with. It exits
`2` for a name that is not a target, with a suggestion, and for a target the command line names itself.

`--graph` shows what both leave out: `skipped: -s` and `skipped: --skip`.
14 changes: 10 additions & 4 deletions src/Nullean.Make.Fs/MakeApp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,17 @@ type MakeApp<'TCase when 'TCase : comparison and 'TCase : not null>
| false, _ ->
eprintfn "Unknown target '%s'." routeKey
return 2
| true, node when isNull node.DtoType && targetArgs.Length > 0 ->
let first = if targetArgs.[0] = "--" && targetArgs.Length > 1 then targetArgs.[1] else targetArgs.[0]
eprintfn "Unexpected argument '%s'. Target '%s' takes no arguments." first routeKey
return 2
| true, node ->
// Each target named on the command line gets the tokens up to the next one; one without a record takes none.
let unexpected =
Invocation.Split(node, targetArgs, graph)
|> Seq.tryFind (fun struct (n, args) -> isNull n.DtoType && args.Length > 0)
match unexpected with
| Some (struct (n, args)) ->
let first = if args.[0] = "--" && args.Length > 1 then args.[1] else args.[0]
eprintfn "Unexpected argument '%s'. Target '%s' takes no arguments." first (String.concat "/" n.Route)
return 2
| None ->
switches.Target <- node
switches.TargetArgs <- targetArgs
switches.SingleTarget <- singleTarget
Expand Down
9 changes: 9 additions & 0 deletions src/Nullean.Make.Fs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ let token = app.Option<string option>("--token", desc = "API token", defaultVa

Read them in target blocks through `.Value`. Help shows each option's type, such as `--config <string>`, and `--token <string?>` for an option type. Both `--token abc` and `--token=abc` work. A value that does not parse, or a missing value, exits `2` before any target runs. Enum options bind by name, ignoring case.

## Choosing what runs

```
build lint test --filter Unit pack # several targets in order; each takes the arguments up to the next
build release --skip docs # leave a target out, with what only it needed
```

See [Choosing what runs](https://argh.nullean.net/make/running).

## Drawing the plan

`--graph` draws what a run would do and runs nothing. It binds the target's arguments, applies `-s` and evaluates
Expand Down
13 changes: 11 additions & 2 deletions src/Nullean.Make.Fs/skills/nullean-make-fs/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ let main argv =
`executes (shell { ... })` adds a body that runs last.
- A record payload is the target's flags (`Test of TestOptions` takes `--filter`). A DU payload is a namespace
(`Pkg of PkgTarget` gives `pkg generate`).
- A dependency can name a payload, `Test { Filter = Some "Unit" }`: the target runs with it. Equal payloads run once,
different payloads once each. Only the named target binds the command line.
- `concurrently [A; B]` in a `command { }` block is a stage that runs side by side (F# reserves `parallel`); stages
run in the order written. `-j N` caps targets at once and `-k` keeps going after a failure. `printfn` output is
prefixed with the target's name; `sh` output keeps the console and is not cancelled.
- Pipe a definition through `onlyWhen (fun () -> ...)`, `after [Lint]`, `cleanup [StopDb]`, `needsEnv ["KEY"]`,
`needsTool ["docker"]` and `describe "..."`.
- `build release --graph` (or `--graph mermaid|json`) draws the plan, skipped targets included, and runs nothing.
`build lint test pack` runs several targets; `--skip docs` leaves one out.
- Global options: `app.Flag("--verbose", short = "-v", desc = "...")`, `app.Option<'T>(...)`, read with `.Value`
inside a block.
- `<run> __wrappers sync --run "dotnet run --project build --"` writes mise, make and just includes with one task per
Expand All @@ -80,8 +89,8 @@ let main argv =
## Gotchas

- Descriptions are the `///` comments on the cases, read from the XML documentation file: the project needs
`<GenerateDocumentationFile>true</GenerateDocumentationFile>`. A `.fsx` script has none; use
`Make.target deps "description" body` there.
`<GenerateDocumentationFile>true</GenerateDocumentationFile>`. A `.fsx` script has none; pipe the target through
`describe "..."` there.
- `sh $"..."` splits only the literal text; each `{value}` stays one argument. Do not build a command string with
`sprintf` and pass it in as one value: it becomes a single argument. Use an `if`, or a list spliced as `{args}`.
- Code in the `match` arm outside the block runs when the graph is read, for every case. Put the work inside
Expand Down
9 changes: 7 additions & 2 deletions src/Nullean.Make/Execution/DepGraphExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ public static async Task<int> ExecuteAsync(TargetNode root, ParsedArgs parsed, B
RunPlan plan;
try
{
var value = source.BindArguments(root, parsed.TargetArgs);
plan = RunPlan.Build([new DepRef(root, value)], source, new PlanOptions(parsed.SingleTarget, EvaluateConditions: parsed.Graph is not null));
// `build lint test --filter Unit pack` names three targets; each binds its own arguments.
var targets = Invocation.Split(root, parsed.TargetArgs, graph);
parsed.TargetArgs = targets[0].Args;
var roots = targets.Select(t => new DepRef(t.Node, source.BindArguments(t.Node, t.Args))).ToList();
var skip = Invocation.ResolveSkips(parsed.Skip, graph);
plan = RunPlan.Build(roots, source, new PlanOptions(parsed.SingleTarget, EvaluateConditions: parsed.Graph is not null, Skip: skip));
}
catch (MakeException ex)
{
Expand All @@ -39,6 +43,7 @@ public static int DrawWholeGraph(BuildGraph graph, GraphFormat format)
try
{
var plan = PlanRenderer.WholeGraph(graph, source, new PlanOptions(SingleTarget: false, EvaluateConditions: true));
// --skip is ignored here: the whole graph shows every target.
PlanRenderer.Write(plan, format, Console.Out);
return 0;
}
Expand Down
108 changes: 108 additions & 0 deletions src/Nullean.Make/Execution/Invocation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
using Nullean.Argh.Matching;
using Nullean.Make.Discovery;

namespace Nullean.Make.Execution;

/// <summary>Splits a command line that names several targets, such as <c>build lint test --filter Unit pack</c>.</summary>
internal static class Invocation
{
/// <summary>
/// Splits the tokens after the first target's route into that target's arguments and the targets after it. A token
/// starts the next target when it names one, is not the value of the option before it, and the current target takes
/// no positional arguments. Everything after <c>--</c> stays with the current target.
/// </summary>
public static List<(TargetNode Node, string[] Args)> Split(TargetNode first, string[] args, BuildGraph graph)
{
var result = new List<(TargetNode Node, string[] Args)>();
var node = first;
var current = new List<string>();
var options = Options(node);
for (var i = 0; i < args.Length; i++)
{
var token = args[i];
if (token == "--")
{
current.AddRange(args[i..]);
break;
}
if (token.StartsWith('-'))
{
current.Add(token);
// The value of an option that takes one stays with it, even when it names a target.
if (!token.Contains('=') && options.TakesValue(token) && i + 1 < args.Length)
current.Add(args[++i]);
continue;
}
if (!options.TakesPositionals && MatchRoute(args, i, graph) is { } next)
{
result.Add((node, [.. current]));
node = next.Node;
options = Options(node);
current = new List<string>();
i += next.Consumed - 1;
continue;
}
current.Add(token);
}
result.Add((node, [.. current]));
return result;
}

/// <summary>The longest route starting at <c>args[start]</c>, such as <c>pkg generate</c>, and how many tokens it took.</summary>
private static (TargetNode Node, int Consumed)? MatchRoute(string[] args, int start, BuildGraph graph)
{
(TargetNode, int)? best = null;
var segments = new List<string>();
for (var i = start; i < args.Length && !args[i].StartsWith('-'); i++)
{
segments.Add(args[i].ToLowerInvariant());
var key = string.Join("/", segments);
if (graph.ByRoute.TryGetValue(key, out var node))
best = (node, segments.Count);
else if (!graph.ByRoute.Keys.Any(k => k.StartsWith(key + "/", StringComparison.OrdinalIgnoreCase)))
break;
}
return best;
}

private sealed record TargetOptions(HashSet<string> ValueOptions, bool TakesPositionals)
{
public bool TakesValue(string token) => ValueOptions.Contains(token.TrimStart('-'));
}

private static TargetOptions Options(TargetNode node)
{
if (node.DtoType is null)
return new TargetOptions(new HashSet<string>(StringComparer.OrdinalIgnoreCase), false);
var described = DtoOptions.Describe(node.DtoType);
return new TargetOptions(
described
.Where(o => !o.IsPositional && !o.IsRest && !o.IsSwitch && !IsFSharpBoolOption(o.Type))
.Select(o => o.Name)
.ToHashSet(StringComparer.OrdinalIgnoreCase),
described.Any(o => o.IsPositional)
);
}

private static bool IsFSharpBoolOption(Type type) =>
type.IsGenericType && type.GetGenericTypeDefinition().Name == "FSharpOption`1" && type.GetGenericArguments()[0] == typeof(bool);

/// <summary>Resolves the targets of <c>--skip</c>, given as <c>pkg generate</c>, <c>pkg/generate</c> or <c>pkg:generate</c>.</summary>
public static HashSet<TargetNode> ResolveSkips(IEnumerable<string> names, BuildGraph graph)
{
var skipped = new HashSet<TargetNode>();
foreach (var name in names)
{
var key = string.Join("/", name.Split([' ', '/', ':'], StringSplitOptions.RemoveEmptyEntries)).ToLowerInvariant();
if (graph.ByRoute.TryGetValue(key, out var node))
{
skipped.Add(node);
continue;
}
var suggestions = FuzzyMatch.FindClosest(key, graph.ByRoute.Keys.Select(k => k.Replace('/', ' ')), 3);
var hint = suggestions.Count > 0 ? $" Did you mean '{suggestions[0]}'?" : "";
throw new MakeException($"Unknown target '{name}' for '--skip'.{hint}", 2);
}
return skipped;
}
}
4 changes: 4 additions & 0 deletions src/Nullean.Make/Execution/PlanRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ private static void WriteChildren(List<Line> children, string indent, TextWriter
{
SkipReason.SingleTarget => Dim(" skipped: -s"),
SkipReason.Condition => Dim(" skipped: its condition is false"),
SkipReason.Excluded => Dim(" skipped: --skip"),
_ => ""
};

Expand Down Expand Up @@ -313,6 +314,9 @@ private static void WriteSkipped(Utf8JsonWriter json, SkipReason? reason)
case SkipReason.Condition:
json.WriteString("skipped", "condition");
break;
case SkipReason.Excluded:
json.WriteString("skipped", "excluded");
break;
default:
json.WriteNull("skipped");
break;
Expand Down
15 changes: 13 additions & 2 deletions src/Nullean.Make/Execution/RunPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ internal enum SkipReason
SingleTarget,

/// <summary>Its condition returned <see langword="false"/>, so its body does not run.</summary>
Condition
Condition,

/// <summary><c>--skip</c> left it out of the plan.</summary>
Excluded
}

/// <summary>One target with one value in a run: it runs once, however many targets depend on it.</summary>
Expand Down Expand Up @@ -48,7 +51,8 @@ internal sealed record PlannedItem(TargetInstance? Instance, string Name, SkipRe
/// <param name="SingleTarget">Skip the named targets' gates, as <c>-s</c> does.</param>
/// <param name="EvaluateConditions">Evaluate each condition while planning, so a drawn plan shows what it skips.</param>
/// <param name="ChainRoots">Run the named targets in order, each after the one before it.</param>
internal sealed record PlanOptions(bool SingleTarget, bool EvaluateConditions = false, bool ChainRoots = true);
/// <param name="Skip">Targets <c>--skip</c> leaves out, whatever their value, with the dependencies only they needed.</param>
internal sealed record PlanOptions(bool SingleTarget, bool EvaluateConditions = false, bool ChainRoots = true, IReadOnlySet<TargetNode>? Skip = null);

/// <summary>The instances a run contains, in an order that respects every prerequisite.</summary>
internal sealed class RunPlan
Expand Down Expand Up @@ -101,6 +105,8 @@ public static RunPlan Build(IReadOnlyList<DepRef> roots, ITargetSource source, P
TargetInstance? previous = null;
foreach (var root in roots)
{
if (options.Skip?.Contains(root.Node) == true)
throw new MakeException($"'--skip' names '{string.Join(" ", root.Node.Route)}', which the command line runs.", 2);
var instance = builder.Visit(root, isRoot: true, previous is null || !options.ChainRoots ? [] : [previous]);
instance.IsRoot = true;
rootInstances.Add(instance);
Expand Down Expand Up @@ -245,6 +251,11 @@ public TargetInstance Visit(DepRef reference, bool isRoot, IReadOnlyList<TargetI
TargetInstance? previous = null;
foreach (var item in stage.Items)
{
if (options.Skip?.Contains(item.Node) == true)
{
items.Add(new PlannedItem(null, ValueDisplay.Name(item.Node, source.FormatValue(item.Node, Resolve(item))), SkipReason.Excluded));
continue;
}
IReadOnlyList<TargetInstance> wait = stage.Parallel || previous is null ? barrier : [.. barrier, previous];
var child = Visit(item, isRoot: false, wait);
items.Add(new PlannedItem(child, child.Name, null));
Expand Down
3 changes: 3 additions & 0 deletions src/Nullean.Make/Execution/RunSwitches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public static bool TryRead(IReadOnlyList<string> args, ref int i, ParsedArgs par
case "-j" or "--jobs":
parsed.Jobs = ParseJobs(Value(args, ref i, name));
return true;
case "--skip":
parsed.Skip.AddRange(Value(args, ref i, name).Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries));
return true;
case "-k" or "--keep-going":
parsed.KeepGoing = true;
i++;
Expand Down
3 changes: 2 additions & 1 deletion src/Nullean.Make/Help/MakeHelpPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static void PrintRoot(BuildGraph graph, string scriptName)
var nsNames = nsTargets.Select(t => t.Route[0]).Distinct().OrderBy(x => x).ToList();

Console.WriteLine($" {CliHelpFormatting.Section("Usage:")}");
Console.WriteLine($" {scriptName} <command|target> [options]");
Console.WriteLine($" {scriptName} <command|target> [options] [<target> [options]...]");
if (nsNames.Count > 0)
Console.WriteLine($" {scriptName} <namespace> <target> [options]");
if (graph.Default is { } defaultTarget)
Expand Down Expand Up @@ -276,6 +276,7 @@ private static void PrintGlobalOptions(BuildGraph graph, string scriptName)
$" {CliHelpFormatting.Placeholder($"{Short("k")}--keep-going"),-30} After a failure, finish the targets that do not depend on it"
);
Console.WriteLine($" {CliHelpFormatting.Placeholder(" --output <mode>"),-30} Output of targets running side by side: prefixed or grouped");
Console.WriteLine($" {CliHelpFormatting.Placeholder(" --skip <target>"),-30} Leave a target out of the plan, with what only it needed");

foreach (var opt in graph.GlobalOptions)
{
Expand Down
3 changes: 3 additions & 0 deletions src/Nullean.Make/Parsing/ArgvParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ internal sealed class ParsedArgs

/// <summary><c>--output</c>: how the output of targets that run side by side reaches the console.</summary>
public Execution.OutputMode? Output { get; set; }

/// <summary><c>--skip</c>: targets the plan leaves out, with the dependencies only they needed.</summary>
public List<string> Skip { get; } = new();
public string? HelpTarget { get; set; }
}

Expand Down
9 changes: 9 additions & 0 deletions src/Nullean.Make/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ A target's description is the summary of its case type's XML doc comment, such a

A case that is itself a union becomes a namespace: `union Db(Migrate, Seed)` inside `union Target(..., Db)` gives `db migrate` and `db seed`, and `db --help` lists them. Case type names must be unique across the whole union, including nested unions.

## Choosing what runs

```
build lint test --filter Unit pack # several targets in order; each takes the arguments up to the next
build release --skip docs # leave a target out, with what only it needed
```

See [Choosing what runs](https://argh.nullean.net/make/running).

## Drawing the plan

`--graph` draws what a run would do and runs nothing. It binds the target's arguments, applies `-s` and evaluates
Expand Down
10 changes: 10 additions & 0 deletions src/Nullean.Make/skills/nullean-make/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ union Target(Clean, Build, Test, Pkg, Release);
- `app.Target(deps, body)`: dependencies run first, once each. `app.Command(requires, composes)` sequences other
targets: `requires` are gates, `composes` the work, in order; an optional third argument runs last.
- A case record's constructor parameters are that target's flags: `Test(string? Filter = null)` takes `--filter`.
- A dependency can name a value, `app.Target([new Test("Unit")], ...)`: the target runs with it. Equal values run
once, different values once each. Only the named target binds the command line.
- `app.Command().Requires(new Test()).Parallel(new PackNuget(), new Docs()).Composes(new Publish())` runs a stage
side by side; stages run in declared order. `-j N` caps targets at once, `-k` keeps going after a failure, and an
async body can take the cancellation token: `app.Target(async ct => ...)`.
- On a target builder: `.OnlyWhen(() => ...)` skips the body, `.After(new Lint())` orders it after `lint` when both
run, `.Cleanup(new StopDb())` runs at the end even after a failure, `.NeedsEnv("KEY")` / `.NeedsTool("docker")` are
checked before anything starts.
- `./build.cs release --graph` (or `--graph mermaid|json`) draws the plan, skipped targets included, and runs
nothing. `./build.cs lint test pack` runs several targets; `--skip docs` leaves one out.
- A nested union is a namespace: `Pkg` gives `pkg generate` and `pkg validate`. Match it with
`Pkg { Value: Generate }` and create it with `new Pkg(new Generate())`.
- A non-zero exit code from `Exec` fails the target, and `RunAsync` returns `1`. A bad or missing option value
Expand Down
Loading
Loading