#!/usr/bin/env node
import{a as l}from"./chunk-JBABAK44.js";import{a as d}from"./chunk-RLNOQILG.js";var D={name:"ag-find-files",async execute(g,s){let n=l("ag-find-files",g,{path:{short:"p",long:"path",type:"string"},name:{short:"n",long:"name",type:"string"}});if(!n.ok)return n.error;let{flags:o,positional:r}=n.result,i=o.name||r[0],c=o.path||r[1]||".";if(!i)return{stdout:"",stderr:`Usage: ag-find-files <name_pattern> [path]
`,exitCode:1};let p=s.fs.resolvePath(s.cwd,c),t=[],f=async e=>{let m=await s.fs.stat(e);if((e.split("/").pop()||"").includes(i)&&t.push(e),!m.isDirectory)return;let u=await s.fs.readdir(e);for(let a of u){let h=s.fs.resolvePath(e,a);a==="node_modules"||a===".git"||await f(h)}};try{return await f(p),{stdout:t.join(`
`)+(t.length>0?`
`:""),stderr:t.length===0?`No matching files found.
`:"",exitCode:0}}catch(e){return{stdout:"",stderr:`ag-find-files: ${d(e.message)}
`,exitCode:1}}}};export{D as a};
