refactor: subdirectory layout, mod.nu entry point, test suite#1
refactor: subdirectory layout, mod.nu entry point, test suite#1danielbodnar wants to merge 6 commits intomainfrom
Conversation
- completions/dagger.nu: move from root, export nu-complete helpers - tests/completions.test.nu: 12 tests covering all completion helpers and registered extern commands (std/assert, no mutable closures) - README: update install path
nu-complete helpers are exported (export def) — appropriate for a completions module where helpers are part of the public API. Tests use top-level `use` so scope commands reflects parser-time scope and helpers are callable without subshell gymnastics. Also adds mod.nu entry point following nushell-modules convention.
There was a problem hiding this comment.
Pull request overview
Refactors the repository into a more nushell-module-friendly layout by introducing a root mod.nu entrypoint, moving the completions into a subdirectory, and adding a Nushell test suite to validate exported helpers/externs and re-export behavior.
Changes:
- Add
mod.nuas the root module entrypoint that re-exports the completions module. - Export
nu-completehelper defs fromcompletions/dagger.nuand add a newtests/completions.test.nusuite. - Update README manual install instructions to reflect the new file layout.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
tests/completions.test.nu |
Adds a Nushell test runner validating helper outputs, extern registration, uniqueness, and mod.nu integration. |
mod.nu |
Introduces root entrypoint that export uses the completions module. |
completions/dagger.nu |
Switches completion helper defs to export def to make them part of the module’s public surface. |
README.md |
Updates manual installation guidance for the new directory layout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let out = ^nu --no-config-file -c $" | ||
| use '/workspaces/code/github.com/danielbodnar/dagger.nu/mod.nu' * |
There was a problem hiding this comment.
test mod.nu entry point hard-codes an absolute workspace path (/workspaces/code/github.com/danielbodnar/dagger.nu/mod.nu). This will fail for anyone running the tests outside that specific directory layout (CI, local clones, Windows). Compute the module path dynamically from the test file location (e.g., via $env.FILE_PWD + path join + path expand) and interpolate that into the ^nu -c string instead of embedding a fixed path.
| let out = ^nu --no-config-file -c $" | |
| use '/workspaces/code/github.com/danielbodnar/dagger.nu/mod.nu' * | |
| let mod-path = ([$env.FILE_PWD ".." "mod.nu"] | path join | path expand) | |
| let out = ^nu --no-config-file -c $" | |
| use '($mod-path)' * |
| Clone the repo, then add to `config.nu`: | ||
|
|
||
| ```nushell | ||
| use dagger.nu * | ||
| ``` | ||
|
|
||
| Or source it directly: | ||
|
|
||
| ```nushell | ||
| use /path/to/dagger.nu * | ||
| use /path/to/dagger.nu/completions/dagger.nu * | ||
| ``` |
There was a problem hiding this comment.
README manual install now points users at use /path/to/dagger.nu/completions/dagger.nu *, but this PR introduces mod.nu specifically as the stable root entry point. Consider updating the README to recommend use /path/to/dagger.nu/mod.nu * (and optionally mention the completions file as an alternative) to keep documentation consistent with the new layout and intended public entrypoint.
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@danielbodnar I've opened a new pull request, #2, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: danielbodnar <1790726+danielbodnar@users.noreply.github.com> Agent-Logs-Url: https://github.com/danielbodnar/dagger.nu/sessions/af9bae3d-4462-46d8-9910-dfabe586c1a5
Co-authored-by: danielbodnar <1790726+danielbodnar@users.noreply.github.com> Agent-Logs-Url: https://github.com/danielbodnar/dagger.nu/sessions/3240f946-4491-400e-9c07-4ea1ddf3a298
fix: portable mod.nu path in tests, recommend mod.nu in README
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # Top-level use — brings externs and helpers into parser scope so | ||
| # scope commands reflects them and helper calls resolve without a subshell. | ||
| use ../completions/dagger.nu * |
There was a problem hiding this comment.
use ../completions/dagger.nu * is a brittle relative path. When running the test as documented (nu tests/completions.test.nu from the repo root), this resolves to ../completions/... and can fail depending on how use resolves relative paths. Build the path from $env.FILE_PWD (like the mod.nu test does) so the suite works regardless of the current working directory.
| use ../completions/dagger.nu * | |
| use ($env.FILE_PWD | path join ".." "completions" "dagger.nu") * |
Summary
dagger.nu→completions/dagger.nuto make room for future commands, modules, etc.mod.nuroot entry point following the nushell-modules pattern (export use completions/dagger.nu *)tests/completions.test.nuwith 13 passing testsTest suite covers
usemod.nucorrectly re-exports everythingDesign note:
export deffornu-completehelpersThe reference nushell-modules repo uses non-exported helpers. For this completions-focused repo,
export defis the right call — the helpers are the public API (users can callnu-complete dagger sdks | get valueto inspect options). This also avoids subshell gymnastics in tests.Install path change