cli_router 0.1.0
cli_router: ^0.1.0 copied to clipboard
Router for CLIs inspired by shelf_router that uses spaces between segments instead of /
Changelog #
All notable changes to this project will be documented in this file.
The format loosely follows Keep a Changelog and the project adheres to Semantic Versioning.
0.1.0 - 2026-07-13 #
Added #
CliRouter({CliNotFoundHandler? onNotFound}): an application can now decide how an unmatched invocation is reported and with which exit code. The hook receives aCliNotFound(original args + sinks) and is inherited by every mounted subrouter. Presentation belongs to the application; the router only knows what failed to match.ListedCommandnow carries the route metadata the router already had and used to discard:positionals(the names of the<param>segments, in order) andmodule(the mount the command was registered under).ListedCommand,CliNotFoundandCliNotFoundHandlerare exported frompackage:cli_router/cli_router.dart.
Fixed #
- Positionals after the matched route were dropped when the invocation carried no flags (
help mathreached the handler with an emptypositionals). They are now captured whether or not a flag follows.
Changed #
- Minor version bump:
^0.0.zpermits no upgrade under Dart's caret semantics, so0.0.xreleases pinned consumers to an exact patch. From^0.1.0on, consumers receive compatible updates without editing their pubspec.
Nothing breaks: with no onNotFound supplied, the router still prints Command not found or invalid usage. plus its listing to stderr and returns 64.
0.0.3 - 2026-04-18 #
Fixed #
- Empty route
''no longer acts as catch-all. It now only matches whenargsis genuinely empty, preventing it from intercepting flag-only (--help) or positional args before mounts are evaluated.
0.0.2 - 2025-10-13 #
Changed #
- Shortened
descriptioninpubspec.yamlto meet pub.dev guidelines. - Updated
homepage→ GitHub anddocumentation→ pub.dev for valid URLs. - Applied
dart format .anddart fix --applyto match Dart style. - Updated
README.mdwith version^0.0.2and added pub badge. - Completed MIT
LICENSEtext.
Removed #
- Removed unused
test/cli_router_test.dart.
Docs #
- Improved DartDoc coverage for
CliRequestmethods. - Fixed unresolved reference in doc comment for
CliRequest.matchedCommand.
Fixed #
- Minor analyzer and formatting warnings reported by pana.
0.0.1 - 2025-10-13 #
Added #
- Initial release of cli_router.
- Space-based routing for commands:
cmd('route subroute', handler). - Nested routers via
mount('prefix', subRouter)orcmd('prefix', subRouter). - Dynamic parameters
<id>and wildcard*. - GNU-style flag parsing (
--k v,--k=v,-abc,--no-k). - Shelf-like middlewares with
use(). - Helpers:
flagBool,flagInt,flagDouble,flagString,param('id'). - Simple help output and exit codes (
0,64).
- Space-based routing for commands: