import{c as a}from"./chunk-AH77CRWX.js";import{a as c}from"./chunk-HWKDQ44K.js";import{a as u,b as p}from"./chunk-74CEPOFO.js";import*as g from"diff";var b={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:["-u, --unified     output unified diff format (default)","-q, --brief       report only whether files differ","-s, --report-identical-files  report when files are the same","-i, --ignore-case  ignore case differences","    --help        display this help and exit"]},C={unified:{short:"u",long:"unified",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},L={name:"diff",async execute(d,e){if(p(d))return u(b);let t=c("diff",d,C);if(!t.ok)return t.error;let m=t.result.flags.brief,h=t.result.flags.reportSame,y=t.result.flags.ignoreCase,l=t.result.positional;if(t.result.flags.unified,l.length<2)return{stdout:"",stderr:`diff: missing operand
`,exitCode:2};let i,s,[r,o]=l;try{i=r==="-"?a(e.stdin):await e.fs.readFile(e.fs.resolvePath(e.cwd,r))}catch{return{stdout:"",stderr:`diff: ${r}: No such file or directory
`,exitCode:2}}try{s=o==="-"?a(e.stdin):await e.fs.readFile(e.fs.resolvePath(e.cwd,o))}catch{return{stdout:"",stderr:`diff: ${o}: No such file or directory
`,exitCode:2}}let f=i,n=s;return y&&(f=f.toLowerCase(),n=n.toLowerCase()),f===n?h?{stdout:`Files ${r} and ${o} are identical
`,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0}:m?{stdout:`Files ${r} and ${o} differ
`,stderr:"",exitCode:1}:{stdout:g.createTwoFilesPatch(r,o,i,s,"","",{context:3}),stderr:"",exitCode:1}}},P={name:"diff",flags:[{flag:"-u",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"boolean"}],needsArgs:!0,minArgs:2};export{L as a,P as b};
