1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! CLI argument parsing
use clap::{Parser, Subcommand};
use std::path::PathBuf;
#[derive(Parser)]
#[command(name = "aster")]
#[command(about = "AST manipulation and conversion tool", long_about = None)]
#[command(after_help = "Use 'aster <command> --help' for more information.")]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand)]
pub enum Commands {
/// Convert Rust source to S-expression AST
#[command(visible_alias = "ast")]
ToAst {
/// Input Rust file (or - for stdin)
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output file (or - for stdout)
#[arg(short, long, value_name = "FILE")]
output: Option<PathBuf>,
/// Use compact formatting
#[arg(short, long)]
compact: bool,
/// Continue processing after errors, generating comments for unsupported items
#[arg(long)]
continue_after_error: bool,
},
/// Convert S-expression to Rust source
ToRust {
/// Input S-expression file (or - for stdin)
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output file (or - for stdout)
#[arg(short, long, value_name = "FILE")]
output: Option<PathBuf>,
},
/// Verify round-trip conversion
Verify {
/// Input Rust file
#[arg(value_name = "FILE")]
input: PathBuf,
/// Verbose output
#[arg(short, long)]
verbose: bool,
},
}