Repository navigation
feat(#271): labelle add pack / labelle add feature subcommand
#272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| const std = @import("std"); | ||
| const assembler_proc = @import("assembler_proc.zig"); | ||
| const config = @import("config.zig"); | ||
|
|
||
| /// Scaffold a pack or a feature-unit by delegating to the assembler binary. | ||
| /// | ||
| /// Packs initiative (umbrella labelle-engine#651, RFC-packs §7, #271). | ||
| /// `labelle add pack <name>` / `labelle add feature <kind> <name>` scaffold | ||
| /// the two authoring units the Packs RFC defines. Like `labelle init`, the | ||
| /// heavy lifting is assembler knowledge — the `pack.labelle` schema and the | ||
| /// game-root convention layout are the assembler's — so the CLI is a thin | ||
| /// forwarder: it hands `add ...` to `labelle-assembler add ...` verbatim | ||
| /// and propagates the exit code. | ||
| /// | ||
| /// `cmd_args` is `["pack", name]` or `["feature", kind, name]` (plus any | ||
| /// flags), collected unchanged by the cli.zig arg parser. The assembler | ||
| /// validates the shape and prints diagnostics. | ||
| /// | ||
| /// Resolution: `add` runs inside an existing project, so `resolve` reads | ||
| /// the pinned `assembler_version` from `./project.labelle` (falling back to | ||
| /// the CLI-paired default when there is none). The `add` subcommand needs | ||
| /// assembler protocol >= 4. | ||
| /// | ||
| /// Project guard: `add` is dispatched from cli.zig's standalone-command | ||
| /// switch, so it never passes through the `readProjectConfig` guard that | ||
| /// project-scoped commands (`generate`/`build`/`run`) use. Without an | ||
| /// explicit check here, `labelle add pack foo` run in the wrong cwd (home | ||
| /// dir, a mistyped path) would scaffold `packs/`/`components/`/`scripts/` | ||
| /// THERE. Require a `project.labelle` in cwd first and emit the same | ||
| /// "No project.labelle found" error the project-scoped guard does. | ||
| pub fn cmdAdd(allocator: std.mem.Allocator, cmd_args: []const []const u8) !void { | ||
| if (!config.projectExists(".")) { | ||
| config.printNoProjectError("."); | ||
| // Match the project-scoped guard's non-zero outcome without a | ||
| // Zig error-return trace (same pattern as `android doctor`). | ||
| std.process.exit(1); | ||
| } | ||
| try assembler_proc.runSubcommand(allocator, ".", "add", cmd_args); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because
addis returned from the standalone-command switch, it skips the existingconfig.readProjectConfigguard below and will invoke the assembler even when the current directory is not a Labelle project. In that situation a mistyped cwd such as a parent directory or home directory createspacks/,components/, orscripts/there instead of producing the same “No project.labelle found” error as project-scoped commands; validate the manifest or route through the normal project-dir path before forwarding.Useful? React with 👍 / 👎.