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 7036a76 commit a2934e7Copy full SHA for a2934e7
1 file changed
implement-shell-tools/ls/ls.mjs
@@ -0,0 +1,23 @@
1
+import { promises as fs } from "node:fs";
2
+import { program } from "commander";
3
+
4
+program
5
+ .name("ls implementation")
6
+ .description("ls -1 program")
7
+ .argument("[path]", "The path to process")
8
+ .option("-1, --one-per-line", "one file per line");
9
+program.parse();
10
11
+const path = program.args[0] || ".";
12
+const options = program.opts();
13
+try {
14
+ const files = await fs.readdir(path);
15
+ console.log(files);
16
+ if (options.onePerLine) {
17
+ for (const file of files) {
18
+ console.log(file);
19
+ }
20
21
+} catch (error) {
22
+ console.error(error.message);
23
+}
0 commit comments