Restructure and start working on CLI

This commit is contained in:
Fabian Stamm
2025-05-26 16:43:40 +02:00
parent 883b6da7eb
commit b61518de00
38 changed files with 134 additions and 8 deletions

52
src/main.rs Normal file
View File

@ -0,0 +1,52 @@
use anyhow::Result;
use clap::{Parser, Subcommand};
use libjrpc::{targets::rust::RustCompiler, FileProcessor};
#[derive(Parser)]
struct Cli {
#[command(subcommand)]
command: Commands,
#[arg(short, long, global = true)]
verbose: bool,
}
#[derive(Subcommand)]
enum Commands {
Compile {
input: String,
output: String,
#[arg(short, long)]
definition: Option<String>,
},
Targets,
}
pub fn main() -> Result<()> {
let cli = Cli::parse();
if cli.verbose {
log::set_max_level(log::LevelFilter::Trace);
} else {
log::set_max_level(log::LevelFilter::Warn);
}
match cli.command {
Commands::Compile {
input,
output,
definition,
} => {
let mut fp = FileProcessor::new();
let ir = fp.start_compile(&input)?;
libjrpc::targets::compile::<RustCompiler>(ir, &output)?;
//TODO: Implement definition output!
}
Commands::Targets => {
panic!("Not yet implemented!")
}
}
Ok(())
}