Parse command line args

This commit is contained in:
Joscha 2022-11-16 23:56:58 +01:00
parent 6234038460
commit 4aecce8107
3 changed files with 241 additions and 2 deletions

View file

@ -1,7 +1,36 @@
use std::fs;
use std::path::PathBuf;
use clap::Parser;
mod builtin;
mod table;
mod value;
fn main() {
println!("Hello, world!");
#[derive(Parser)]
enum Command {
Parse { file: PathBuf },
}
#[derive(Parser)]
struct Args {
#[command(subcommand)]
command: Command,
}
/// Foo
fn main() -> anyhow::Result<()> {
let args = Args::parse();
match args.command {
Command::Parse { file } => {
let content = fs::read_to_string(&file)?;
print!("{content}");
if !content.ends_with('\n') {
println!();
}
}
}
Ok(())
}