Parameters and binding
Method parameters become CLI flags automatically. No attribute boilerplate for the common case.
Nullean.Argh supports several parameter binding modes:
- Flags - named options (
--output-dir ./bin), derived from C# parameter names - Arguments - positional parameters (
myapp deploy production), marked with[Argument] - DTO binding - expand records/classes into individual flags with
[AsParameters] - Custom parsers -
IArgumentParser<T>for types with no built-in support - Validation - DataAnnotations and filesystem path attributes
| Category | Types |
|---|---|
| Primitives | string, int, long, double, float, decimal, bool, bool? |
| System | enum, FileInfo, DirectoryInfo, Uri |
| Collections | List<T>, T[] |
Collection flags accept the flag multiple times by default. Use [CollectionSyntax(Separator=",")] for comma-separated input instead. For variadic positionals, use [Argument] T[] or [Argument] params T[].
public static Task<int> Deploy(string[] targets) { … }
myapp deploy --targets web --targets api
public static Task<int> Deploy([CollectionSyntax(Separator = ",")] string[] tags) { … }
myapp deploy --tags blue,green
The source generator reads your method signatures at build time and emits typed parsers for each parameter. Parameter names are converted from camelCase to kebab-case for CLI flags.
Parameters with default values are optional; those without are required.