Add temporal range types and reusable options groups#6
Merged
carldebilly merged 3 commits intomainfrom Mar 4, 2026
Merged
Conversation
Introduce ReplDateRange, ReplDateTimeRange, and ReplDateTimeOffsetRange as first-class parameter types with two literal syntaxes: range (start..end) and duration (start@duration). Parser uses ReadOnlySpan<char> internally to minimize string allocations during split operations.
Introduce ReplOptionsGroupAttribute to mark classes whose public writable properties expand into individual command options. Property names are auto-lowered from PascalCase to camelCase for canonical tokens. Groups support aliases, reverse aliases, value aliases, and all existing option attributes on properties. Name collisions are detected at registration. Also adds documentation for both options groups and temporal ranges, and friendly type names for range types in help/docs output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Two recurring pain points when building CLI apps with Repl Toolkit:
Repeated option sets — commands that share the same options (output format, verbosity, pagination…) force developers to duplicate parameters on every handler. This is error-prone and makes it hard to keep option names and aliases consistent across commands.
Date/time intervals — querying logs, generating reports, or filtering audit trails almost always requires a "from/to" range. Today this means two separate parameters, manual validation that
to >= from, and no compact syntax for "start + duration" patterns.What changed
Reusable options groups (
[ReplOptionsGroup])A class decorated with
[ReplOptionsGroup]can now be used directly as a handler parameter. Its public writable properties are expanded into individual command options, exactly as if they were declared on the handler itself.Format→--format)[ReplOption],[ReplArgument],[ReplValueAlias]) work on propertiesTemporal range types
Three new record types represent date/time intervals:
ReplDateRange,ReplDateTimeRange, andReplDateTimeOffsetRange. They support two compact literal syntaxes:2024-01-15..2024-02-152024-01-15@30dReversed ranges (
To < From) produce a validation error. Duration syntax reuses the existingTimeSpanLiteralParser.