")}catch(t){a.innerHTML+="
"+l(t.message)+"
"}}else a.innerHTML+="
'"+s+"' does not exist.
"}else a.innerHTML+='
Invalid command
';r.value="",window.scrollTo(0,document.body.scrollHeight)}});var p=[{name:"help",description:"Show this help message.",help:"help [command]",run:e=>{if(""==e){let r="Baked commands:\n\n";p.sort((e,r)=>e.name.localeCompare(r.name));for(let e=0;e
a.innerHTML=""},{name:"exit",description:"Exit the console.",help:"exit",run:e=>(a.hidden=!0,a.style.display="none",r.parentElement.style.display="none",window.close(),"")},{name:"echo",description:"Echo a message.",help:"echo [message]",run:e=>e},{name:"date",description:"Show the current date and time.",help:"date or date UTC",run:e=>{let r=new Date;if(""==e)return r.toString();if("UTC"==e)return r.toUTCString();throw new Error("Invalid arguments.")}},{name:"cd",description:"Change the current working directory.",help:"cd [directory]",run:e=>{if(""==e)throw new Error("No directory specified.");if(fs.existsSync(e))return process.chdir(e),"";throw new Error("Directory '"+e+"' does not exist.")}},{name:"ls",description:"List the contents of the current directory.",help:"ls [options]\n\nOptions:\n\n--help\tShow this help message.\n-l\tList files in long format.",run:e=>{if(""==e){let r=t.map(e=>[e.name,e.type]),n=(r.sort((e,r)=>e[0]r[0]?1:0),"");for(let e=0;e"+r[e][0]+"Â Â Â ":"file"==r[e][1]?n+=""+r[e][0]+"Â Â Â ":n+=""+r[e][0]+"Â Â Â ";return n}if("-l"!=e)throw new Error("Invalid arguments.");{let r="";for(let e=0;e"+n.name+"Â Â Â "+n.size+"Â Â Â "+n.date+"\n":"file"==n.type?r+=n.permissions+" . . . "+n.name+"Â Â Â "+n.size+"Â Â Â "+n.date+"\n":r+=n.permissions+" . . . "+n.name+"Â Â Â "+n.size+"Â Â Â "+n.date+"\n"}return r}}},{name:"cat",description:"Display the cats.",help:"cat",run:e=>''},{name:"mkdir",description:"Create a new directory.",help:"mkdir [directory]",run:e=>{if(""==e)throw new Error("No directory specified.");return t.push({name:e,type:"dir",date:new Date,permissions:"rwxr-xr-x"}),"We created the directory sir."}},{name:"rm",description:"Remove a file or directory.",help:"rm [file]",run:e=>{if(""==e)throw new Error("No file specified.");if(e.includes("rf"))throw new Error("We can't do that sir.");var r=e;for(let e=0;e'Welcome to the console!'},{name:"finger",description:"Display information about a user using the Finger service.",help:"finger [user]@[host]",run:r=>{if(""==r)throw new Error("No user specified.");{r="https://the-finger-api.balbona.me/finger/"+r;let e=new XMLHttpRequest;if(e.open("GET",r,!1),e.send(null),200!=e.status&&400!=e.status)throw new Error("Failed to get user information.");if(response=JSON.parse(e.response),console.log(response),void 0!==response.error)throw new Error(response.error);return response.result}}},{name:"op",description:"Grant operator privileges to a user.",help:"op [user]",run:e=>{if(""==e)throw new Error("No user specified.");return"Granted operator privileges to "+e+"."}},{name:"deop",description:"Revoke operator privileges from a user.",help:"deop [user]",run:e=>{if(""==e)throw new Error("No user specified.");return"Revoked operator privileges from "+e+"."}}],t=(activeDirectory="/",[{name:"file1.txt",type:"file",size:"1KB",date:"1/1/2018",permissions:"rwxr-xr-x"},{name:"bench.py",type:"file",size:"1KB",date:"1/1/2018",permissions:"rw-r--r--"},{name:"readme.txt",type:"file",size:"1KB",date:"1/1/2018",permissions:"rw-r--r--"},{name:"homework",type:"dir",size:"",date:"1/1/2018",permissions:"rwxr-xr-x",files:[{name:"file1.txt",type:"file",size:"1KB",date:"1/1/2018",permissions:"rwxr-xr-x"}]}]);