import{a as $}from"./chunk-44UOCSGV.js";import{a as y}from"./chunk-HWKDQ44K.js";import{a as u,b as h}from"./chunk-74CEPOFO.js";var C={name:"mv",summary:"move (rename) files",usage:"mv [OPTION]... SOURCE... DEST",options:["-f, --force       do not prompt before overwriting","-n, --no-clobber  do not overwrite an existing file","-v, --verbose     explain what is being done","    --help        display this help and exit"]},P={force:{short:"f",long:"force",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},O={name:"mv",async execute(m,t){if(h(m))return u(C);let s=y("mv",m,P);if(!s.ok)return s.error;let p=s.result.flags.force,d=s.result.flags.noClobber,w=s.result.flags.verbose,i=s.result.positional;if(d&&(p=!1),i.length<2)return{stdout:"",stderr:`mv: missing destination file operand
`,exitCode:1};let r=i.pop()??"",g=i,n=t.fs.resolvePath(t.cwd,r),v="",f="",b=0,a=!1;try{a=(await t.fs.stat(n)).isDirectory}catch{}if(g.length>1&&!a)return{stdout:"",stderr:`mv: target '${r}' is not a directory
`,exitCode:1};for(let e of g)try{let c=t.fs.resolvePath(t.cwd,e),o=n;if(a){let l=e.split("/").pop()||e;o=n==="/"?`/${l}`:`${n}/${l}`}if(d)try{await t.fs.stat(o);continue}catch{}if(await t.fs.mv(c,o),w){let l=a?`${r}/${e.split("/").pop()||e}`:r;v+=`renamed '${e}' -> '${l}'
`}}catch(c){let o=$(c);o.includes("ENOENT")||o.includes("no such file")?f+=`mv: cannot stat '${e}': No such file or directory
`:f+=`mv: cannot move '${e}': ${o}
`,b=1}return{stdout:v,stderr:f,exitCode:b}}},x={name:"mv",flags:[{flag:"-f",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0,minArgs:2};export{O as a,x as b};
