Skip to content

fix: add --package flag to component add/remove/list commands#5420

Closed
rustsoldev wants to merge 2 commits intoDioxusLabs:mainfrom
rustsoldev:fix/component-add-package-flag
Closed

fix: add --package flag to component add/remove/list commands#5420
rustsoldev wants to merge 2 commits intoDioxusLabs:mainfrom
rustsoldev:fix/component-add-package-flag

Conversation

@rustsoldev
Copy link
Copy Markdown

Summary

Closes #5367

  • dx component add in a workspace with multiple binaries suggests using --package flag, but the flag didn't exist on the component subcommands
  • Added --package (-p) flag to Add, Remove, and List variants of ComponentCommand
  • The flag is passed through resolve_config()find_main_package() to correctly resolve the target package

Changes

  • packages/cli/src/cli/component.rs — Added --package option to Add, Remove, List variants and updated resolve_config() to accept package parameter
  • packages/cli/src/logging.rs — Updated pattern matches to include new package field

Test plan

  • cargo check -p dioxus-cli passes (25s, zero errors)

🤖 Generated with Claude Code

The error message in `find_main_package()` suggests using `--package`
when multiple binaries exist in a workspace, but the component
subcommands didn't actually accept this flag. Now `Add`, `Remove`,
and `List` variants pass the package option through to
`resolve_config()` → `find_main_package()`.

Closes DioxusLabs#5367

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rustsoldev rustsoldev requested a review from a team as a code owner March 26, 2026 21:24
Self::List { registry } => {
let config = Self::resolve_config().await?;
Self::List { registry, package } => {
let config = Self::resolve_config(package).await?;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like this only changes where the config is read from? components_root still points to the workspace so this won't add components to a subcrate like I would expect with a --package argument

…ents_root and global_assets_root

When --package is specified, components and assets should be written
to that subcrate's directory, not the workspace root.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jkelleyrtp jkelleyrtp added the cli Related to the dioxus-cli program label Mar 28, 2026
@jkelleyrtp jkelleyrtp closed this Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to the dioxus-cli program

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dx component add does not correctly suggests --package flag when in workspace

3 participants