mod commands;
use std::path::PathBuf;
use anyhow::Result;
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(name = "cpioutil")]
#[command(author, version, about = "CPIO archive utility", long_about = None)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
List {
archive: PathBuf,
#[arg(short, long)]
long: bool,
},
Info {
archive: PathBuf,
},
Create {
directory: PathBuf,
#[arg(short, long)]
output: PathBuf,
#[arg(long)]
crc: bool,
},
Extract {
archive: PathBuf,
#[arg(short, long)]
output: PathBuf,
},
Cat {
archive: PathBuf,
path: String,
},
}
fn main() -> Result<()> {
let cli = Cli::parse();
match cli.command {
Commands::List { archive, long } => commands::list(archive, long),
Commands::Info { archive } => commands::info(archive),
Commands::Create {
directory,
output,
crc,
} => commands::create(directory, output, crc),
Commands::Extract { archive, output } => commands::extract(archive, output),
Commands::Cat { archive, path } => commands::cat(archive, &path),
}
}