use std::sync::LazyLock;
use indoc::indoc;
use super::colorize_examples;
use super::{output, parse_file, run_op};
static EXAMPLES: LazyLock<String> = LazyLock::new(|| {
colorize_examples(indoc! {r#"
yerba remove config.yml "tags" "rust"
yerba remove videos.yml "[0].speakers" "Alice"
"#})
});
#[derive(clap::Args)]
#[command(
about = "Remove an item from a sequence by its value",
arg_required_else_help = true,
after_help = EXAMPLES.as_str()
)]
pub struct Args {
file: String,
selector: String,
value: String,
#[arg(long)]
dry_run: bool,
}
impl Args {
pub fn run(self) {
let mut document = parse_file(&self.file);
run_op(|| document.remove(&self.selector, &self.value));
output(&self.file, &document, self.dry_run);
}
}