import{a as p}from"./chunk-HWKDQ44K.js";import{a as l,b as u}from"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";import*as c from"diff";var y={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"}},$={name:"diff",async execute(d,e){if(u(d))return l(y);let t=p("diff",d,C);if(!t.ok)return t.error;let h=t.result.flags.brief,g=t.result.flags.reportSame,m=t.result.flags.ignoreCase,a=t.result.positional;if(t.result.flags.unified,a.length<2)return{stdout:"",stderr:`diff: missing operand
`,exitCode:2};let o,s,[r,i]=a;try{o=r==="-"?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=i==="-"?e.stdin:await e.fs.readFile(e.fs.resolvePath(e.cwd,i))}catch{return{stdout:"",stderr:`diff: ${i}: No such file or directory
`,exitCode:2}}let f=o,n=s;return m&&(f=f.toLowerCase(),n=n.toLowerCase()),f===n?g?{stdout:`Files ${r} and ${i} are identical
`,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0}:h?{stdout:`Files ${r} and ${i} differ
`,stderr:"",exitCode:1}:{stdout:c.createTwoFilesPatch(r,i,o,s,"","",{context:3}),stderr:"",exitCode:1}}};export{$ as diffCommand};
