32 lines
803 B
Rust
32 lines
803 B
Rust
use clap::{Parser};
|
|
use std::path::PathBuf;
|
|
|
|
#[derive(Parser)]
|
|
#[clap(about = "Output a file content or stdin to a c++ header/source file", long_about = None)]
|
|
struct CommandLine {
|
|
#[clap(short='f', long="file")]
|
|
input_file: Option<PathBuf>,
|
|
|
|
#[clap(short='o')]
|
|
output_file: PathBuf,
|
|
}
|
|
|
|
fn run_main() -> tool_helper::Result<()> {
|
|
match CommandLine::try_parse() {
|
|
Ok(cmd) => {
|
|
let _output = tool_helper::open_output(cmd.input_file)?;
|
|
return Ok(());
|
|
},
|
|
Err(error) => Err(tool_helper::Error::new(-1, error.to_string()))
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
match run_main() {
|
|
Ok(_) => println!("All good"),
|
|
Err(error) => {
|
|
eprintln!("{}", error.text);
|
|
std::process::exit(error.exit_code);
|
|
}
|
|
}
|
|
} |