view rust/rhg/src/commands/debugrequirements.rs @ 52273:fdecc547a75d stable

rhg-status: rename a variable to be more explicit Possibly we would have caught the looming bug earlier if this had been named closer to what it actual is used for.
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 18 Nov 2024 15:02:59 +0100
parents 37bc3edef76f
children
line wrap: on
line source

use crate::error::CommandError;

pub const HELP_TEXT: &str = "
Print the current repo requirements.
";

pub fn args() -> clap::Command {
    clap::command!("debugrequirements").about(HELP_TEXT)
}

pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
    let repo = invocation.repo?;
    let mut output = String::new();
    let mut requirements: Vec<_> = repo.requirements().iter().collect();
    requirements.sort();
    for req in requirements {
        output.push_str(req);
        output.push('\n');
    }
    invocation.ui.write_stdout(output.as_bytes())?;
    Ok(())
}