Repository navigation
Conversation
Rebuild the command line toolkit on the ecosystem template: - facade (src/lib.alya) + data models (src/types.alya) + focused engines (src/core/spec.alya, parser.alya, formatter.alya, errors.alya, internal.alya) - complete option grammar: long, inline, short, attached, clustered, negated, repeatable options and the -- terminator - hierarchical subcommands with aliases and command-scoped options - structured CliError diagnostics instead of plain strings - typed accessors (get_int, get_bool) and a provided-value tracker - feature-gated slices: help (usage screens), strict (throwing and recovering parses), env (environment variable fallback) - fluent builder API next to the functional API - 148 assertions across six test suites, demo, and benchmarks
AI code review (advisory only — never merges)Risk: 🟢 low The layered rewrite is internally consistent and every changed .alya file passes fmt/lint/check; the only concrete issues are a stale Alya version (0.0.20 vs the manifest's 0.0.21) in the release/issue tooling and a usage line that drops the parent segment for nested commands. The two lint/check FAILs (src/core/utils.alya, tests/test_flags_advanced.alya) are the files this PR removes/renames to internal.alya and test_flags.alya; no surviving module imports them, so they are expected missing-path noise rather than build breakage. Static: General notes:
Fixed since last review:
Automated review. Treat as untrusted advice: verify before acting. |
Address the findings of the automated code review on #6: - a command re-declaring a global option no longer lists it twice in the usage screen; the command scope wins, as it does in the parser - the shadowed global option is validated only once, so a diagnostic is never reported twice - a value given before the command name is no longer reset to the command default when the command scope is entered Adds coverage for the shadowed-option scenario (154 assertions).
|
Thanks for the automated review. The findings were checked against the code:
Duplicated option in the command usage screen (info) — real, fixed in
The scenario is now covered by the test suite ( |
Audit of the rewritten package found two real defects: - the demo called \outcome.context()\, but CliResult had no such accessor; the compiler silently bound the call to the free facade function, so the success path misbehaved at runtime. Adds the accessor, exercises both strict branches in the demo, and covers the result context in the test suite - the environment fallback was guarded by an empty value, so an option with a non-empty default never fell back to the environment. The lookup now keys off whether the option was provided, and the env slice gains test coverage (the negative path always, the positive path when the variable is set) Also documents the behaviour decisions (unknown input is reported, the command scope wins, the command line wins over the environment, and diagnostics must be rebuilt before they are thrown).
| end | ||
|
|
||
| # Builds the usage line of a command. | ||
| function formatter_command_usage(app: CliApp, cmd: CliCommand, arguments: array) -> string |
There was a problem hiding this comment.
minor: formatter_command_usage builds the usage line as app.name + " " + cmd.name, so a nested command such as remote add (see examples/demo.alya) renders as forge add [OPTIONS], dropping the remote parent segment, even though the parser tracks the full command path. When rendering a nested command's usage line, include the parent path segment instead of only the leaf name.
Summary
Rebuilds the
clipackage from scratch on the ecosystem template. The package now follows the standard layered layout (facade + data models + focused engines) instead of the previous flat implementation, and the whole public API is reworked around typed models, structured diagnostics, and feature-gated slices.The version is bumped
0.1.0→0.2.0because the public API changes are breaking.Architecture
src/core/internal.alyadeliberately declares nopubsymbol: an Alya module without public items shares its whole surface with sibling modules, so the shared helpers stay reachable inside the package while remaining invisible to package consumers.What is new
--output dist), inline (--output=dist), short (-o dist), attached (-oDist), clustered (-abc), negated (--no-color), repeatable (-I a -I b), and the--terminator.build⇄b).CliErrorvalues withcode,subject, andmessagereplace the plain error strings;ErrorCodecovers unknown options, missing values, missing required options, invalid choices, missing arguments, unknown commands, and invalid usage.get_intandget_boolconvert option values,get_allreturns the collected values of a repeatable option.ctx.has(name)reports only the values that actually appeared on the command line, so an option left at its declared default counts as absent.-I srcis visible through--includeas well.env_option).help(usage screens),strict(parse_strict/try_parse), andenv, each with a descriptive fallback stub so the public surface stays stable in slim builds.app.flag(...)) next to the functional API (cli::add_flag(app, ...)), both over the same engines.Migration notes
cli::new(name, desc, ver)cli::new_app(name, desc, ver)cli::command(name, desc, aliases)cli::new_command(name, desc, aliases)cli::app_add_flag(app, spec, desc)cli::add_flag(app, spec, desc)/app.flag(spec, desc)cli::cmd_add_option(cmd, ...)cli::command_add_option(cmd, ...)/cmd.option(...)cli::ctx_get_flag(ctx, name)cli::get_flag(ctx, name)/ctx.get_flag(name)cli::ctx_get_all(ctx, name)cli::get_all(ctx, name)/ctx.get_all(name)cli::ctx_has_errors(ctx)cli::has_errors(ctx)/ctx.has_errors()cli::help(app, cmd)cli::format_help(app)/cli::format_command_help(app, cmd)cli::cli_format_version(app)cli::format_version(app)cli::cli_format_errors(errors)cli::format_errors(errors)ctx.get_errors()→string[]ctx.get_errors()→CliError[](err.code,err.subject,err.message)Verification
alya testalya test --no-default-featuresalya fmt . --checkalya lint . --checkalya run examples/demo.alyaalya run benches/bench_basic.alyaalya doc . -o docs --markdownThe template compliance audit (
check_template_compliance.py --packages cli) reports Compliant with GitHub verification enabled.Notes
main); the old implementation stays available onmainand in thev0.1.0release.alya.tomldescription.