mirror of
https://github.com/astral-sh/ruff
synced 2026-01-21 05:20:49 -05:00
Include both ruff help and ruff help check in README (#2325)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//! This library only exists to enable the Ruff internal tooling (`ruff_dev`)
|
||||
//! to automatically update the `ruff --help` output in the `README.md`.
|
||||
//! to automatically update the `ruff help` output in the `README.md`.
|
||||
//!
|
||||
//! For the actual Ruff library, see [`ruff`].
|
||||
#![forbid(unsafe_code)]
|
||||
@@ -10,7 +10,26 @@ mod args;
|
||||
|
||||
use clap::CommandFactory;
|
||||
|
||||
/// Returns the output of `ruff --help`.
|
||||
pub fn help() -> String {
|
||||
/// Returns the output of `ruff help`.
|
||||
pub fn command_help() -> String {
|
||||
args::Args::command().render_help().to_string()
|
||||
}
|
||||
|
||||
/// Returns the output of `ruff help check`.
|
||||
pub fn subcommand_help() -> String {
|
||||
let output = args::Args::command()
|
||||
.find_subcommand_mut("check")
|
||||
.expect("`check` subcommand not found")
|
||||
.render_help()
|
||||
.to_string();
|
||||
|
||||
// Replace the header, to fix Clap's omission of "ruff" on the "Usage: check" line.
|
||||
let header =
|
||||
"Run Ruff on the given files or directories (default)\n\nUsage: check [OPTIONS] [FILES]...";
|
||||
let replacement =
|
||||
"Run Ruff on the given files or directories\n\nUsage: ruff check [OPTIONS] [FILES]...";
|
||||
let output = output
|
||||
.strip_prefix(header)
|
||||
.expect("`output` does not start expected header");
|
||||
format!("{replacement}{output}")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user