refactor: Rename CLI arg structs from Cli to Args

Technically the command-line interface (CLI) encompasses both input and
output, so naming the input structs 'Args' is more accurate than 'Cli'.
This commit is contained in:
Martin Fischer 2023-01-25 03:53:40 +01:00 committed by Charlie Marsh
parent b346f74915
commit d9ead4e6df
15 changed files with 86 additions and 95 deletions

View file

@ -1,15 +1,14 @@
//! Generate CLI help.
use anyhow::Result;
use clap::Args;
use crate::utils::replace_readme_section;
const HELP_BEGIN_PRAGMA: &str = "<!-- Begin auto-generated cli help. -->";
const HELP_END_PRAGMA: &str = "<!-- End auto-generated cli help. -->";
#[derive(Args)]
pub struct Cli {
#[derive(clap::Args)]
pub struct Args {
/// Write the generated help to stdout (rather than to `README.md`).
#[arg(long)]
pub(crate) dry_run: bool,
@ -19,10 +18,10 @@ fn trim_lines(s: &str) -> String {
s.lines().map(str::trim_end).collect::<Vec<_>>().join("\n")
}
pub fn main(cli: &Cli) -> Result<()> {
pub fn main(args: &Args) -> Result<()> {
let output = trim_lines(ruff_cli::help().trim());
if cli.dry_run {
if args.dry_run {
print!("{output}");
} else {
replace_readme_section(