DKNet

Select a named job from command-line arguments

Part of DKNet.AspCore.Extensions. JobSelector.Select finds the first argument that is not an option and matches it against a caller-supplied set of job names:

using DKNet.AspCore.Extensions.Jobs;
var selection = JobSelector.Select(["--environment", "Development", "SEED"], ["seed", "warm"]);
Console.WriteLine(selection.JobName); // seed
Console.WriteLine(selection.IsRecognized); // True

JobSelector skips option arguments, finds the first positional candidate and matches a canonical known name without executing it.

Arguments starting with - are skipped. An option without = also consumes the following argument; an inline option such as --environment=Development consumes only itself. Matching is case-insensitive and preserves the canonical known name.

JobSelection carries RequestedJobName, nullable canonical JobName, IsRecognized, and a copied KnownJobNames list. HasJobName means a candidate was found, even if unknown. No candidate produces null names and false recognition; an unknown candidate preserves the requested string but no canonical name.

⚠️ Gotchas & limits