File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # import process from "node:process";
2- # import { promises as fs } from "node:fs";
3- # import { program } from "commander";
4-
5- # program
6- # .name("list-files-in-directory")
7- # .description("List all files and directories in a directory")
8- # .argument("<path>", "The file path to process")
9- # .option("-1, --one", "Output one entry per line")
10- # .option("-a", "List all files & directories, including hidden ones");
11-
12- # program.parse();
13-
14- # const path = program.args[0];
15-
16- # const options = program.opts();
17-
18- # const directoryContent = await fs.readdir(path);
19-
20- # let allContent = directoryContent;
21-
22- # if (!options.a) {
23- # allContent = directoryContent.filter(name => !name.startsWith("."));
24- # }
25-
26- # for (const item of allContent) {
27- # if (options.one) {
28- # process.stdout.write(item + "\n");
29- # } else {
30- # process.stdout.write(item + " ");
31- # }
32- # }
33-
341import argparse
352import os
363
You can’t perform that action at this time.
0 commit comments