mirror of
https://github.com/astral-sh/ruff
synced 2026-01-21 13:30:49 -05:00
https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args Signed-off-by: Anders Kaseorg <andersk@mit.edu>
23 lines
505 B
Rust
23 lines
505 B
Rust
//! Print the AST for a given Python file.
|
|
|
|
use std::fs;
|
|
use std::path::PathBuf;
|
|
|
|
use anyhow::Result;
|
|
use clap::Args;
|
|
use rustpython_parser::parser;
|
|
|
|
#[derive(Args)]
|
|
pub struct Cli {
|
|
/// Python file for which to generate the AST.
|
|
#[arg(required = true)]
|
|
file: PathBuf,
|
|
}
|
|
|
|
pub fn main(cli: &Cli) -> Result<()> {
|
|
let contents = fs::read_to_string(&cli.file)?;
|
|
let python_ast = parser::parse_program(&contents, &cli.file.to_string_lossy())?;
|
|
println!("{python_ast:#?}");
|
|
Ok(())
|
|
}
|