Restructure and start working on CLI
This commit is contained in:
52
src/main.rs
Normal file
52
src/main.rs
Normal 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(())
|
||||
}
|
Reference in New Issue
Block a user