From a181ca7a3d45df234a83230977fe01f3f68e8503 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sat, 14 Jan 2023 07:34:13 +0100 Subject: [PATCH] Reduce the API of ruff_cli to ruff_cli::help() --- ruff_cli/src/lib.rs | 8 ++++++-- ruff_dev/src/generate_cli_help.rs | 6 ++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ruff_cli/src/lib.rs b/ruff_cli/src/lib.rs index 2357f4f452..36093747d0 100644 --- a/ruff_cli/src/lib.rs +++ b/ruff_cli/src/lib.rs @@ -2,5 +2,9 @@ mod cli; -// used by ruff_dev::generate_cli_help -pub use cli::Cli; +use clap::CommandFactory; + +/// Returns the output of `ruff --help`. +pub fn help() -> String { + cli::Cli::command().render_help().to_string() +} diff --git a/ruff_dev/src/generate_cli_help.rs b/ruff_dev/src/generate_cli_help.rs index b128cb33d6..920f7451e7 100644 --- a/ruff_dev/src/generate_cli_help.rs +++ b/ruff_dev/src/generate_cli_help.rs @@ -1,8 +1,7 @@ //! Generate CLI help. use anyhow::Result; -use clap::{Args, CommandFactory}; -use ruff_cli::Cli as MainCli; +use clap::Args; use crate::utils::replace_readme_section; @@ -21,8 +20,7 @@ fn trim_lines(s: &str) -> String { } pub fn main(cli: &Cli) -> Result<()> { - let mut cmd = MainCli::command(); - let output = trim_lines(cmd.render_help().to_string().trim()); + let output = trim_lines(ruff_cli::help().trim()); if cli.dry_run { print!("{output}");