-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.js
More file actions
38 lines (34 loc) · 881 Bytes
/
Copy pathdemo.js
File metadata and controls
38 lines (34 loc) · 881 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
29
30
31
32
33
34
35
36
37
38
const directoryTools=require("./index");
process.stdout.write("Befehl Eingeben!\n$ ");
process.stdin.on("data",buffer=>{
const command=(buffer
.toString("utf-8")
.trim()
);
if(
command==="q"||
command==="exit"||
command==="quit"||
command==="close"||
command==="stop"||
command==="end"
){
console.log("\nProgram Geschlossen!");
process.exit(0);
}
else if(command.startsWith("list ")){
const path=command.substring("list ".length);
const files=directoryTools.getFiles(path);
if(!files){
process.stdout.write(`Nicht Gefunden!\n$ `);
return;
}
console.log(`${files.join("\n")}\n\n${files.length} Dateien Gefunden!`);
}
else if(command.startsWith("mkdirs ")){
const path=command.substring("mkdirs ".length);
directoryTools.makeDirectoriesInPath(path);
}
else console.log("Befehl nicht gefunden!");
process.stdout.write("$ ");
});