Fix --deno-* option parsing and add cache command#97
Conversation
Previously extractDenoOptions() enforced that only --deno-no-* options could be used without values, causing --deno-reload to fail. This was incorrect because Deno's --reload flag accepts optional values: --reload (reload all dependencies) --reload=<mods> (reload specific modules) Changes: - Removed strict validation from extractDenoOptions() to allow any --deno-* option without '=' to be treated as a boolean flag - Connected -r/--reload option to denoArgs (was previously unused) - Updated documentation to clarify "with value" vs "without value" - Added comprehensive tests for extractDenoOptions() Now these are all equivalent: probitas run -r probitas run --reload probitas run --deno-reload
Users often need to pre-download scenario dependencies before running tests, especially in CI/CD environments or when working offline. The new `probitas cache` command wraps `deno cache` with the same file discovery and configuration patterns as other CLI commands. Changes: - Added `probitas cache` command that runs `deno cache` on scenarios - Extended _deno.ts helper to support -r/--reload option - Created usage-cache.txt help documentation - Updated README and main help with cache command Usage: probitas cache # Cache all scenario dependencies probitas cache -r # Force re-download probitas cache api/ # Cache specific directory probitas cache --include "e2e/**/*.probitas.ts" The command follows the same patterns as fmt/lint/check for consistency and automatically discovers scenario files using probitas.json config.
There was a problem hiding this comment.
Pull request overview
This PR fixes --deno-* option parsing to support boolean flags without requiring = syntax, connects the existing -r/--reload option to the Deno subprocess, and adds a new probitas cache command for pre-downloading scenario dependencies.
Key changes:
- Simplified
extractDenoOptions()to treat any--deno-*option without=as a boolean flag - Connected
-r/--reloadshorthand to Deno subprocess inrunandlistcommands - Added
probitas cachecommand withuseConfigoption to respectdeno.json/deno.lock
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/cli/utils.ts | Simplified extractDenoOptions() to remove strict validation and support boolean flags without = |
| src/cli/utils_test.ts | Added comprehensive test coverage for the new extractDenoOptions() behavior |
| src/cli/commands/run.ts | Connected -r/--reload option to denoArgs for Deno subprocess |
| src/cli/commands/list.ts | Connected -r/--reload option to denoArgs for Deno subprocess |
| src/cli/commands/cache.ts | New command to run deno cache on scenario files with config support |
| src/cli/commands/_deno.ts | Added supportReload and useConfig options to make the helper more flexible |
| src/cli/commands/mod.ts | Exported new cacheCommand |
| src/cli.ts | Wired up cache command in CLI dispatcher |
| assets/usage.txt | Added cache command to main help text |
| assets/usage-run.txt | Updated --deno-* option documentation with new syntax |
| assets/usage-list.txt | Updated --deno-* option documentation with new syntax |
| assets/usage-cache.txt | Added help text for new cache command |
| README.md | Added cache command to CLI examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Add --reload to denoArgs if -r/--reload is specified | ||
| const finalDenoArgs = parsed.reload ? [...denoArgs, "--reload"] : denoArgs; |
There was a problem hiding this comment.
If a user provides both -r and --deno-reload, this will result in duplicate --reload flags being passed to the Deno subprocess. Consider checking if --reload is already present in denoArgs before adding it.
| // Add --reload to denoArgs if -r/--reload is specified | |
| const finalDenoArgs = parsed.reload ? [...denoArgs, "--reload"] : denoArgs; | |
| // Add --reload to denoArgs if -r/--reload is specified, avoiding duplicates | |
| const finalDenoArgs = parsed.reload && !denoArgs.includes("--reload") | |
| ? [...denoArgs, "--reload"] | |
| : denoArgs; |
| // Add --reload to denoArgs if -r/--reload is specified | ||
| const finalDenoArgs = parsed.reload ? [...denoArgs, "--reload"] : denoArgs; |
There was a problem hiding this comment.
If a user provides both -r and --deno-reload, this will result in duplicate --reload flags being passed to the Deno subprocess. Consider checking if --reload is already present in denoArgs before adding it.
| // Add --reload to denoArgs if -r/--reload is specified | |
| const finalDenoArgs = parsed.reload ? [...denoArgs, "--reload"] : denoArgs; | |
| // Add --reload to denoArgs if -r/--reload is specified, avoiding duplicates | |
| const finalDenoArgs = parsed.reload && !denoArgs.includes("--reload") | |
| ? [...denoArgs, "--reload"] | |
| : denoArgs; |
Summary
--deno-reloadto work as boolean flag without requiring=-r/--reloadoption todenoArgs(was parsed but unused)probitas cachecommand to pre-download scenario dependenciesuseConfigoption to allow cache command to usedeno.json/deno.lockWhy
1. --deno- Boolean Flags Were Broken*
Users reported that
probitas run --deno-reloadfailed with an error. The issue was thatextractDenoOptions()had overly strict validation that only allowed--deno-no-*options without values. This was incorrect because many Deno flags like--reloadaccept optional values:--reload(reload all dependencies)--reload=<mods>(reload specific modules)The fix simplifies the logic: any
--deno-*option without=is treated as a boolean flag, and options with=are treated as value options. This matches Deno's actual behavior.2. -r/--reload Option Was Dead Code
The run/list commands parsed
-r/--reloadbut never used the value. This has been connected todenoArgsso users can now use-ras a shorthand for--deno-reload.3. Users Need Dependency Pre-caching
In CI/CD environments and offline workflows, users need to pre-download scenario dependencies before running tests. The new
probitas cachecommand wrapsdeno cachewith the same file discovery patterns as other CLI commands (fmt/lint/check), providing a consistent interface.4. Cache Needs Config Files
Unlike fmt/lint/check which intentionally ignore
deno.json(they use probitas-specific rules), the cache command needs to respectdeno.jsonimport maps anddeno.lockto resolve dependencies correctly. AddeduseConfigoption toDenoSubcommandOptionsto make this configurable per command.Test Plan
deno task verify- all tests passprobitas run --deno-reloadworks without errorprobitas run -rworks as shorthandprobitas cachedownloads dependencies and respects deno.jsonprobitas cache -rforces re-download