Skip to content
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

feat: update lock on pixi list #775

Merged
merged 3 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,21 @@ List project's packages. Highlighted packages are explicit dependencies.
- `--sort-by <SORT_BY>`: Sorting strategy [default: name] [possible values: size, name, type]
- `--manifest-path <MANIFEST_PATH>`: the path to `pixi.toml`, 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 lockfile. Without checking the status of the lockfile. It can also be controlled by the `PIXI_FROZEN` environment variable (example: `PIXI_FROZEN=true`).
- `--locked`: only install if the `pixi.lock` is up-to-date with the `pixi.toml`[^1]. It can also be controlled by the `PIXI_LOCKED` environment variable (example: `PIXI_LOCKED=true`). Conflicts with `--frozen`.
- `--no-install`: do not update the environment, only add changed packages to the lock-file. (Implied by `--frozen` and `--locked`)

```shell

```shell
pixi list
pixi list --json-pretty
pixi list --sort-by size
pixi list --platform win-64
pixi list --environment cuda
pixi list --frozen
pixi list --locked
pixi list --no-install
```
Output will look like this, where `python` will be green as it is the package that was explicitly added to the `pixi.toml`:

Expand Down
17 changes: 17 additions & 0 deletions src/cli/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ use std::io;
use std::io::{stdout, Write};
use std::path::PathBuf;

use crate::environment::get_up_to_date_prefix;
use clap::Parser;
use console::Color;
use human_bytes::human_bytes;
use indexmap::IndexMap;
use itertools::Itertools;
use rattler_conda_types::Platform;
use rattler_lock::Package;
Expand Down Expand Up @@ -53,6 +55,13 @@ pub struct Args {
/// The environment to list packages for. Defaults to the default environment.
#[arg(short, long)]
pub environment: Option<String>,

#[clap(flatten)]
pub lock_file_usage: super::LockFileUsageArgs,

/// Don't install the environment, only update the lock-file.
#[arg(long)]
pub no_install: bool,
}

#[derive(Serialize)]
Expand All @@ -75,6 +84,14 @@ pub async fn execute(args: Args) -> miette::Result<()> {
.environment(&environment_name)
.ok_or_else(|| miette::miette!("unknown environment '{environment_name}'"))?;

get_up_to_date_prefix(
ruben-arts marked this conversation as resolved.
Show resolved Hide resolved
&environment,
args.lock_file_usage.into(),
args.no_install,
IndexMap::default(),
)
.await?;

// Load the platform
let platform = args.platform.unwrap_or_else(Platform::current);

Expand Down
Loading