We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2691eee commit 176b4d5Copy full SHA for 176b4d5
1 file changed
implement-shell-tools/ls/myLs.js
@@ -0,0 +1,36 @@
1
+import { program } from "commander";
2
+import { promises as fs } from "node:fs";
3
+import process from "node:process";
4
+
5
+program
6
+ .name("myLs")
7
+ .description("my ls clone")
8
+ .option("-1", "one entry per line")
9
+ .option("-a", "show hidden files")
10
+ .argument("[paths...]", "file or directory paths");
11
12
+program.parse();
13
14
+const opts = program.opts();
15
+let paths = program.args;
16
17
+if (paths.length === 0) {
18
+ paths = ["."];
19
+}
20
21
+for (const path of paths) {
22
+ const entries = await fs.readdir(path);
23
24
+ for (const file of entries) {
25
+ if (!opts.a && file.startsWith(".")) {
26
+ continue;
27
+ }
28
29
+ if (opts["1"]) {
30
+ console.log(file);
31
+ } else {
32
+ console.log(file + " ");
33
34
35
36
0 commit comments