import{t as e}from"./chunk-44UOCSGV-BZ6LfyW2.mjs";import{r as t,t as n}from"./chunk-74CEPOFO-V0JXh91S.mjs";import{t as r}from"./chunk-HWKDQ44K-BJxdK4fT.mjs";var i={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`]},a={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(o,s){if(n(o))return t(i);let c=r(`mv`,o,a);if(!c.ok)return c.error;c.result.flags.force;let l=c.result.flags.noClobber,u=c.result.flags.verbose,d=c.result.positional;if(d.length<2)return{stdout:``,stderr:`mv: missing destination file operand
`,exitCode:1};let f=d.pop()??``,p=d,m=s.fs.resolvePath(s.cwd,f),h=``,g=``,_=0,v=!1;try{v=(await s.fs.stat(m)).isDirectory}catch{}if(p.length>1&&!v)return{stdout:``,stderr:`mv: target '${f}' is not a directory
`,exitCode:1};for(let t of p)try{let e=s.fs.resolvePath(s.cwd,t),n=m;if(v){let e=t.split(`/`).pop()||t;n=m===`/`?`/${e}`:`${m}/${e}`}if(l)try{await s.fs.stat(n);continue}catch{}if(await s.fs.mv(e,n),u){let e=v?`${f}/${t.split(`/`).pop()||t}`:f;h+=`renamed '${t}' -> '${e}'
`}}catch(n){let r=e(n);r.includes(`ENOENT`)||r.includes(`no such file`)?g+=`mv: cannot stat '${t}': No such file or directory
`:g+=`mv: cannot move '${t}': ${r}
`,_=1}return{stdout:h,stderr:g,exitCode:_}}},s={name:`mv`,flags:[{flag:`-f`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0,minArgs:2};export{s as n,o as t};
//# sourceMappingURL=chunk-A4JSPFCI-CQJoYugB.mjs.map