Skip to content

Fix --deno-* option parsing and add cache command#97

Merged
lambdalisue merged 2 commits into
mainfrom
fix/deno-option-parse
Jan 9, 2026
Merged

Fix --deno-* option parsing and add cache command#97
lambdalisue merged 2 commits into
mainfrom
fix/deno-option-parse

Conversation

@lambdalisue
Copy link
Copy Markdown
Member

Summary

  • Fix --deno-reload to work as boolean flag without requiring =
  • Connect -r/--reload option to denoArgs (was parsed but unused)
  • Add probitas cache command to pre-download scenario dependencies
  • Add useConfig option to allow cache command to use deno.json/deno.lock

Why

1. --deno- Boolean Flags Were Broken*

Users reported that probitas run --deno-reload failed with an error. The issue was that extractDenoOptions() had overly strict validation that only allowed --deno-no-* options without values. This was incorrect because many Deno flags like --reload accept 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/--reload but never used the value. This has been connected to denoArgs so users can now use -r as 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 cache command wraps deno cache with 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 respect deno.json import maps and deno.lock to resolve dependencies correctly. Added useConfig option to DenoSubcommandOptions to make this configurable per command.

Test Plan

  • Run deno task verify - all tests pass
  • Test probitas run --deno-reload works without error
  • Test probitas run -r works as shorthand
  • Test probitas cache downloads dependencies and respects deno.json
  • Test probitas cache -r forces re-download

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.
Copilot AI review requested due to automatic review settings January 9, 2026 13:19
@lambdalisue lambdalisue enabled auto-merge January 9, 2026 13:21
@lambdalisue lambdalisue merged commit 12d74bc into main Jan 9, 2026
8 checks passed
@lambdalisue lambdalisue deleted the fix/deno-option-parse branch January 9, 2026 13:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/--reload shorthand to Deno subprocess in run and list commands
  • Added probitas cache command with useConfig option to respect deno.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.

Comment thread src/cli/commands/run.ts
Comment on lines +129 to +130
// Add --reload to denoArgs if -r/--reload is specified
const finalDenoArgs = parsed.reload ? [...denoArgs, "--reload"] : denoArgs;
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// 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;

Copilot uses AI. Check for mistakes.
Comment thread src/cli/commands/list.ts
Comment on lines +109 to +110
// Add --reload to denoArgs if -r/--reload is specified
const finalDenoArgs = parsed.reload ? [...denoArgs, "--reload"] : denoArgs;
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// 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;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants