feat(cli): add env file support#1006
Conversation
📦 BoxLite review — couldn't completepowered by BoxLite |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesCLI environment file support
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant EnvironmentFlags
participant BoxRunner
participant BoxExecutor
participant BoxCommand
CLI->>EnvironmentFlags: Resolve env files and explicit values
EnvironmentFlags-->>CLI: Return environment pairs
CLI->>BoxRunner: Run with environment pairs
BoxRunner->>BoxCommand: Configure command environment
CLI->>BoxExecutor: Execute with environment pairs
BoxExecutor->>BoxCommand: Configure command environment
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/cli/src/commands/create.rs`:
- Line 65: Update to_box_options to resolve self.environment at the beginning
and retain the resulting values locally, before invoking VolumeFlags::apply_to
or creating anonymous volumes. Apply the resolved environment to options.env
after the other option transformations, preserving existing error propagation
for missing or malformed environment files.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b317361e-0b94-4ae0-9b60-c7a7b9d4299b
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (13)
docs/reference/cli/README.mdsrc/cli/Cargo.tomlsrc/cli/README.mdsrc/cli/src/cli.rssrc/cli/src/commands/create.rssrc/cli/src/commands/exec.rssrc/cli/src/commands/run.rssrc/cli/src/environment.rssrc/cli/src/main.rssrc/cli/tests/common/mod.rssrc/cli/tests/create.rssrc/cli/tests/exec.rssrc/cli/tests/run.rs
DorianZheng
left a comment
There was a problem hiding this comment.
notes from a pass over the env-file feature; parser behavior checked against dotenvy 0.15.7 source. the important ones: parse errors echo secret values, ${...} substitution has two surprises (host env wins over the file's own lines; files can't see earlier files), and run -u quietly becomes active.
|
@niyue Please fix the conflicts |
Head branch was pushed to by a user without write access
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/cli/README.md (1)
403-420: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMake the environment behavior scope explicit.
This section appears under
boxlite exec, but the documented rules also apply torunandcreate. Move it to a shared environment section or add an explicit heading such as “Environment behavior forrun,create, andexec” so users of the other commands do not miss the precedence and substitution rules.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/cli/README.md` around lines 403 - 420, Make the environment behavior documentation explicitly apply to run, create, and exec rather than only the surrounding exec section. Update the heading or relocate the section to shared documentation while preserving all existing precedence, substitution, bare-key, and secret-injection rules.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/cli/README.md`:
- Around line 403-420: Make the environment behavior documentation explicitly
apply to run, create, and exec rather than only the surrounding exec section.
Update the heading or relocate the section to shared documentation while
preserving all existing precedence, substitution, bare-key, and secret-injection
rules.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 3300d7e8-0f8c-4895-9a8f-96437c377ae5
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (13)
docs/reference/cli/README.mdsrc/cli/Cargo.tomlsrc/cli/README.mdsrc/cli/src/cli.rssrc/cli/src/commands/create.rssrc/cli/src/commands/exec.rssrc/cli/src/commands/run.rssrc/cli/src/environment.rssrc/cli/src/main.rssrc/cli/tests/common/mod.rssrc/cli/tests/create.rssrc/cli/tests/exec.rssrc/cli/tests/run.rs
🚧 Files skipped from review as they are similar to previous changes (9)
- src/cli/tests/exec.rs
- src/cli/src/main.rs
- src/cli/tests/common/mod.rs
- src/cli/src/environment.rs
- src/cli/src/commands/exec.rs
- src/cli/tests/create.rs
- src/cli/src/commands/create.rs
- src/cli/src/commands/run.rs
- src/cli/src/cli.rs
Summary
Adds repeatable
--env-filesupport toboxlite run,create, andexec, making it easier to configure guest environments without specifying every variable individually.This PR closes #1005
Changes
run,create, andexec.dotenvy, supporting standard dotenv syntax such as quotes, comments, export, escapes, and variable substitution.-evalues taking highest precedence.-e KEY=valueand host lookup behavior for bare-e KEY.How to verify
Summary by CodeRabbit
--env-file FILEsupport toboxlite run,create, andexec.-e/--envtakes precedence.-e KEYcan be loaded from the host environment; if missing, earlier values are removed and a warning is shown.--ttybehavior when standard input is not a TTY.--env-fileexamples and dotenv precedence/override behavior.--tty+--detachscenarios.