view rust/rhg/src/commands/debugrequirements.rs @ 46387:c41ac8985fe4

perf: test the formatting of a command help Since we are about to addd ':' in command name I want this covered. Differential Revision: https://phab.mercurial-scm.org/D9871
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 25 Jan 2021 23:13:01 +0100
parents 8a4914397d02
children d03b0601e0eb
line wrap: on
line source

use crate::commands::Command;
use crate::error::CommandError;
use crate::ui::Ui;
use hg::repo::Repo;
use hg::requirements;

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

pub struct DebugRequirementsCommand {}

impl DebugRequirementsCommand {
    pub fn new() -> Self {
        DebugRequirementsCommand {}
    }
}

impl Command for DebugRequirementsCommand {
    fn run(&self, ui: &Ui) -> Result<(), CommandError> {
        let repo = Repo::find()?;
        let mut output = String::new();
        for req in requirements::load(&repo)? {
            output.push_str(&req);
            output.push('\n');
        }
        ui.write_stdout(output.as_bytes())?;
        Ok(())
    }
}