-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (20 loc) · 888 Bytes
/
Copy pathindex.js
File metadata and controls
28 lines (20 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import process from "node:process"
import readline from "node:readline/promises"
import { handleUserInput } from "./user_input/handleUserInput.js"
import { homedir } from "node:os"
import { printCWD } from "./utils/printCWD.js"
async function fileManager() {
const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
let username = process.argv.find(arg => arg.startsWith("--username"))?.split("=")[1]
|| await rl.question("Please, provide your username: ")
console.log(`Welcome to the File Manager, ${username}!`)
process.chdir(homedir())
printCWD()
rl.on("line",
(line) => line === ".exit" || line === "CLOSE"
? process.exit()
: handleUserInput(line.trim())
)
process.on("exit", () => console.log(`Thank you for using File Manager, ${username}, goodbye!`))
}
await fileManager()