use anyhow::{Context, Result};
use clap::Command;
use i_edit_json::{get::xcli::get_command, set::xcli::cli as set_command};
fn main() -> Result<()> {
let mut app = Command::new("i_edit_json")
.version(env!("CARGO_PKG_VERSION"))
.author("YeMiancheng <ymc.github@gmail.com>")
.about("A lightweight, high-performance JSON field extraction and manipulation tool")
.subcommand(get_command().name("get"))
.subcommand(set_command().name("set"));
let matches = app.clone().get_matches();
match matches.subcommand() {
Some(("get", sub_matches)) => {
i_edit_json::get::xcli::handle_get_command(sub_matches)
.context("Failed to execute get command")?;
}
Some(("set", sub_matches)) => {
i_edit_json::set::xcli::handle_set_command(sub_matches)
.context("Failed to execute set command")?;
}
_ => {
println!("{}", app.render_help());
}
}
Ok(())
}