#!/usr/bin/env node
import {d,h}from'./chunk-WS2N27RX.js';import'./chunk-5TAVYPOV.js';import r from'chalk';async function w(e){let c=process.cwd(),t=e.add,s=e.remove;!t&&!s&&(console.error(r.red(`
  Must specify --add <tag> or --remove <tag>
`)),process.exit(1));let n={};e.type&&(n.type=e.type),e.symbol&&(n.symbol=e.symbol),e.author&&(n.author=e.author),e.from&&(n.dateFrom=e.from),e.to&&(n.dateTo=e.to),e.tags&&(n.tags=e.tags.split(",").map(o=>o.trim()));let g=await d(c,n);if(g.length===0){console.log(r.yellow(`
  No matching entries found
`));return}let f=!!e.dryRun,l=0;for(let o of g){let i=o.tags||[],d;if(t){if(i.includes(t))continue;d=[...i,t];}else {if(!i.includes(s))continue;d=i.filter(a=>a!==s);}if(f){let a=t?r.green(`+${t}`):r.red(`-${s}`);console.log(r.gray(`  [dry-run] ${o.id}: ${a}`));}else {await h(c,o.id,{tags:d});let a=t?r.green(`+${t}`):r.red(`-${s}`);console.log(`  ${o.id}: ${a}`);}l++;}console.log(),console.log(f?r.yellow(`  Dry run: ${l} entries would be updated`):r.green(`  Updated ${l} entries`)),console.log();}export{w as loreRetagCommand};