aboutsummaryrefslogtreecommitdiff
path: root/console
diff options
context:
space:
mode:
authorecho <91651232+exhq@users.noreply.github.com>2022-10-07 11:30:27 +0330
committerecho <91651232+exhq@users.noreply.github.com>2022-10-07 11:30:27 +0330
commit9b87fabba203d1af1f09c317d71645cf2a7b5280 (patch)
treee68d717d01ecd4776590bf2bc4ecaf25ae6d64c3 /console
parentf3238da1d58bac18117422c42cbd2e185e2df1e9 (diff)
downloadexhq.github.io-9b87fabba203d1af1f09c317d71645cf2a7b5280.tar.gz
exhq.github.io-9b87fabba203d1af1f09c317d71645cf2a7b5280.tar.bz2
exhq.github.io-9b87fabba203d1af1f09c317d71645cf2a7b5280.zip
cleaned the code, and added a missing return
Diffstat (limited to 'console')
-rw-r--r--console/src/jsMain/kotlin/main.kt145
1 files changed, 81 insertions, 64 deletions
diff --git a/console/src/jsMain/kotlin/main.kt b/console/src/jsMain/kotlin/main.kt
index a30c8c7..68d5297 100644
--- a/console/src/jsMain/kotlin/main.kt
+++ b/console/src/jsMain/kotlin/main.kt
@@ -13,35 +13,36 @@ import kotlinx.html.js.onLoadFunction
val defaultFileSystem = fileSystem {
- "run"{
+ "run" {
"question" text "what is this folder anyways? is it like stuff that runs before everything?"
}
- "tmp"{
+ "tmp" {
"tentacle-hentai" image "https://cdn.discordapp.com/attachments/832652653292027904/1014832179911610408/Screenshot_20220423_113521.png"
}
- "boot"{
- "grub"{
+ "boot" {
+ "grub" {
"bruh" text " mf you expect me to recreate the entire filesystem? go fuck yourself"
}
}
- "home"{
- "exhq"{
+ "home" {
+ "exhq" {
"kill" image "https://cdn.discordapp.com/attachments/917977729322872853/1015922996126425108/ummkrplmos861.jpg"
"gamering" download "https://cdn.discordapp.com/attachments/985989849813237810/1003346125186674859/2022-07-31-notimezoneforyouraid.mp4"
}
- "nea"{
+ "nea" {
"note" text "lmfao shes gone"
}
}
}
-fun redirect(arg: String){
- if("(https://|http://).*".toRegex().matches(arg)){
+
+fun redirect(arg: String) {
+ if ("(https://|http://).*".toRegex().matches(arg)) {
window.location.href = arg
- }
- else{
+ } else {
window.location.href = "https://$arg"
}
}
+
fun main() {
var startupmsg = "type help to get a list of commands"
val root = document.body!!.append.div()
@@ -56,7 +57,7 @@ fun main() {
backgroundSize = "cover"
backgroundAttachment = BackgroundAttachment.fixed
}
- a{
+ a {
color = Color("#AEC6CF")
}
@@ -71,9 +72,9 @@ fun main() {
console.addMultilineText(startupmsg)
console.fileAccessor!!.cd("/home/exhq")
console.rerender()
- console.registerCommand(command("ls"){
+ console.registerCommand(command("ls") {
val fa = requireFileAccessor()
- val path = when(args.size){
+ val path = when (args.size) {
0 -> "."
1 -> args[0]
else -> {
@@ -82,12 +83,12 @@ fun main() {
}
}
val file = fa.resolve(path)
- if (file == null){
+ if (file == null) {
console.addLine("ls : Could not find file or directory")
return@command
}
- when(file){
- is KFile.Directory ->{
+ when (file) {
+ is KFile.Directory -> {
val longestName = file.files.keys.maxOf { it.length }
file.files.forEach { (name, file) ->
console.addLine(
@@ -102,20 +103,23 @@ fun main() {
})
console.registerCommand(defaultCdCommand("cd"))
console.registerCommand(defaultCwdCommand("cwd", "pwd"))
- console.registerCommand(command("help", "?"){
- console.addMultilineText("""
+ console.registerCommand(command("help", "?") {
+ console.addMultilineText(
+ """
ls - lists stuff in current directory
cd - move to another directory
cat - open files
pwd - shows current directory
there are also a lot of hidden commands ;)
- """.trimIndent())
+ """.trimIndent()
+ )
})
console.registerCommand(command("blahaj", "shark")
-{
- console.addMultilineText("""
+ {
+ console.addMultilineText(
+ """
,(((/
/(((((
((((#(( (//
@@ -133,17 +137,18 @@ fun main() {
.. .............,*%%%%#%((((/
**,,,****//*(##((###(#(((
&#(#/#((((((((#
- """.trimIndent())
+ """.trimIndent()
+ )
})
- console.registerCommand(command("cat"){
- if (args[0] =="*"){
+ console.registerCommand(command("cat") {
+ if (args[0] == "*") {
console.addLine("everything")
return@command
}
val fa = requireFileAccessor()
- val path = when (args.size){
+ val path = when (args.size) {
1 -> args[0]
else -> {
console.addLine("usage: cat [text file]")
@@ -151,23 +156,25 @@ fun main() {
}
}
val file = fa.resolve(path)
- if (file == null){
+ if (file == null) {
console.addLine("cat: could not find file")
+ return@command
}
when (file) {
is KFile.Directory -> console.addLine("cat: Is a directory")
is KFile.Text -> console.addMultilineText(file.text)
- is KFile.Image -> console.addLine("cat: wrong file type")
- is KFile.Download -> console.addLine("cat: wrong file type")
- else -> {console.addLine("lmao wtf did you do this is an error, show it to echo or something")}
+ is KFile.Image, is KFile.Download -> console.addLine("cat: wrong file type")
+ else -> {
+ console.addLine("lmao wtf did you do this is an error, show it to echo or something")
+ }
}
})
- console.registerCommand(command("wget"){
+ console.registerCommand(command("wget") {
val fa = requireFileAccessor()
- val path = when (args.size){
+ val path = when (args.size) {
1 -> args[0]
else -> {
console.addLine("usage: wget [download file]")
@@ -175,14 +182,14 @@ fun main() {
}
}
val file = fa.resolve(path)
- if (file == null){
+ if (file == null) {
console.addLine("wget: could not find file")
+ return@command
}
when (file) {
is KFile.Directory -> console.addLine("wget: Is a directory")
- is KFile.Text -> console.addLine("wget: wrong file type")
- is KFile.Image -> console.addLine("wget: wrong file type")
+ is KFile.Text, is KFile.Image -> console.addLine("wget: wrong file type")
is KFile.Download -> {
val link = document.create.a(file.url)
link.download = file.name.last()
@@ -191,13 +198,16 @@ fun main() {
link.remove()
console.addLine("Download started")
}
- else -> {console.addLine("lmao wtf did you do this is an error, show it to echo or something")}
+
+ else -> {
+ console.addLine("lmao wtf did you do this is an error, show it to echo or something")
+ }
}
})
- console.registerCommand(command("view", "show"){
+ console.registerCommand(command("view", "show") {
val fa = requireFileAccessor()
- val path = when (args.size){
+ val path = when (args.size) {
1 -> args[0]
else -> {
console.addLine("usage: view [image]")
@@ -205,58 +215,65 @@ fun main() {
}
}
val file = fa.resolve(path)
- if (file == null){
+ if (file == null) {
console.addLine("view: could not find file")
+ return@command
}
when (file) {
is KFile.Directory -> console.addLine("view: Is a directory")
- is KFile.Text -> console.addLine("view: wrong file type")
- is KFile.Image -> console.addLine(document.create.p {
+ is KFile.Text, is KFile.Download -> console.addLine("view: wrong file type")
+ is KFile.Image -> console.addLine(document.create.p {
img(src = file.url) {
this.onLoadFunction = { console.scrollDown() }
}
})
- is KFile.Download -> console.addLine("view: wrong file type")
- else -> {console.addLine("lmao wtf did you do this is an error, show it to echo or something")}
+
+ else -> {
+ console.addLine("lmao wtf did you do this is an error, show it to echo or something")
+ }
}
})
- console.registerCommand(command("sudo"){
+ console.registerCommand(command("sudo") {
//testing
//val funny = console.fileAccessor!!.currentDir.joinToString("/", "/")
var str = ""
- for (e in args){
- str += "$e "
- }
- if(str == "rm -rf /* " || str == "rm -rf / "){
- console.addLine("haha funny xd im laughing so hard rn lmfao xddddddddddddd HAHAHAHAHAHAH")
- }
-
- else{
+ for (e in args) {
+ str += "$e "
+ }
+ if (str == "rm -rf /* " || str == "rm -rf / ") {
+ console.addLine("haha funny xd im laughing so hard rn lmfao xddddddddddddd HAHAHAHAHAHAH")
+ } else {
console.addLine("bro you don have the password smh")
- }
+ }
})
- console.registerCommand(command("vscode", "vsc", "code"){
+ console.registerCommand(command("vscode", "vsc", "code") {
console.addLine("ew microsoft")
redirect("https://www.poketube.fun/watch?v=lpiB2wMc49g")
})
- console.registerCommand(command("testredirect"){
- redirect(args[0])
+ console.registerCommand(command("testredirect") {
+ redirect(args[0])
})
- console.registerCommand(command("clear"){
+ console.registerCommand(command("clear") {
console.addLine("im too lazy to implement it correctly")
window.location.reload()
})
- console.registerCommand(command("poketube"){
- if (args.isEmpty()){
+ console.registerCommand(command("poketube") {
+ if (args.isEmpty()) {
console.addLine("turns your nasty youtube link into a good untracked poketube link :) \nusage: poketube <youtube link>")
- }
- else{
- if("(https://|http://)?((www\\.)?youtube.com/watch\\?)v=[a-zA-Z1-9]+.+".toRegex().matches(args[0])){
+ } else {
+ if ("(https://|http://)?((www\\.)?youtube.com/watch\\?)v=[a-zA-Z1-9]+.+".toRegex().matches(args[0])) {
val arg = args[0]
- val funny = "https://poketube.fun/watch?"+args[0].subSequence(arg.indexOf("watch?")+6,arg.length)
- console.addLine(document.create.a(funny) { this.text("https://poketube.fun/watch?"+args[0].subSequence(arg.indexOf("watch?")+6,arg.length)) })
+ val funny = "https://poketube.fun/watch?" + args[0].subSequence(arg.indexOf("watch?") + 6, arg.length)
+ console.addLine(document.create.a(funny) {
+ this.text(
+ "https://poketube.fun/watch?" + args[0].subSequence(
+ arg.indexOf("watch?") + 6,
+ arg.length
+ )
+ )
+ })
}
}