diff --git a/docs/reference/cli.md b/docs/reference/cli.md index 0570383d6..774ad7067 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -351,6 +351,7 @@ List project's packages. Highlighted packages are explicit dependencies. - `--json`: Whether to output in json format. - `--json-pretty`: Whether to output in pretty json format - `--sort-by `: Sorting strategy [default: name] [possible values: size, name, type] +- `--explicit (-x)`: Only list the packages that are explicitly added to the [manifest file](configuration.md). - `--manifest-path `: The path to [manifest file](configuration.md), by default it searches for one in the parent directories. - `--environment (-e)`: The environment's packages to list, if non is provided the default environment's packages will be listed. - `--frozen`: install the environment as defined in the lock file, doesn't update `pixi.lock` if it isn't up-to-date with [manifest file](configuration.md). It can also be controlled by the `PIXI_FROZEN` environment variable (example: `PIXI_FROZEN=true`). @@ -360,6 +361,7 @@ List project's packages. Highlighted packages are explicit dependencies. ```shell pixi list pixi list --json-pretty +pixi list --explicit pixi list --sort-by size pixi list --platform win-64 pixi list --environment cuda diff --git a/src/cli/list.rs b/src/cli/list.rs index 015e1c4cf..50c86503e 100644 --- a/src/cli/list.rs +++ b/src/cli/list.rs @@ -65,6 +65,10 @@ pub struct Args { /// Don't install the environment for pypi solving, only update the lock-file if it can solve without installing. #[arg(long)] pub no_install: bool, + + /// Only list packages that are explicitly defined in the project. + #[arg(short = 'x', long)] + pub explicit: bool, } fn serde_skip_is_editable(editable: &bool) -> bool { @@ -181,6 +185,14 @@ pub async fn execute(args: Args) -> miette::Result<()> { .collect::>(); } + // Filter packages by explicit if needed + if args.explicit { + packages_to_output = packages_to_output + .into_iter() + .filter(|p| p.is_explicit) + .collect::>(); + } + // Sort according to the sorting strategy match args.sort_by { SortBy::Size => {