#!/usr/bin/env node
import{b as c}from"./chunk-HI7TGUGZ.js";import{a as p}from"./chunk-JBABAK44.js";import{a as l,b as u}from"./chunk-GTNBSMZR.js";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"]},b={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"}},x={name:"diff",async execute(a,e){if(u(a))return l(y);let t=p("diff",a,b);if(!t.ok)return t.error;let g=t.result.flags.brief,h=t.result.flags.reportSame,m=t.result.flags.ignoreCase,d=t.result.positional;if(t.result.flags.unified,d.length<2)return{stdout:"",stderr:`diff: missing operand
`,exitCode:2};let i,s,[r,o]=d;try{i=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=o==="-"?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 m&&(f=f.toLowerCase(),n=n.toLowerCase()),f===n?h?{stdout:`Files ${r} and ${o} are identical
`,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0}:g?{stdout:`Files ${r} and ${o} differ
`,stderr:"",exitCode:1}:{stdout:c(r,o,i,s,"","",{context:3}),stderr:"",exitCode:1}}},L={name:"diff",flags:[{flag:"-u",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"boolean"}],needsArgs:!0,minArgs:2};export{x as a,L as b};
