Skip to content

Commit 5c64429

Browse files
committed
further added comments to ls
1 parent d4720b1 commit 5c64429

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

  • implement-shell-tools/ls

‎implement-shell-tools/ls/ls.js‎

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
const fs = require("fs");
22
const { allowedNodeEnvironmentFlags } = require("process");
33

4-
const flagHandlers = {
5-
1: Flag1,
6-
a: Flaga,
7-
};
8-
9-
let printInList = false;
10-
let showAll = false;
11-
12-
ls(process.argv);
13-
14-
// ----------
15-
4+
//
5+
// ===== ls Procedure =====
166
function ls(args) {
177
const userArgs = args.slice(2);
188

@@ -28,6 +18,13 @@ function ls(args) {
2818

2919
//
3020
// ===== Flag Handling =====
21+
const flagHandlers = {
22+
1: Flag1,
23+
a: Flaga,
24+
};
25+
26+
let printInList = false;
27+
let showAll = false;
3128

3229
function getFlags(userArgs) {
3330
return userArgs
@@ -63,8 +60,7 @@ function Flaga() {
6360
}
6461

6562
//
66-
// ===== Extracting data from arguments =====
67-
63+
// ===== Extracting Data From Arguments =====
6864
function getCurrentWorkingDirectory(args) {
6965
const index = args[1].lastIndexOf("/");
7066
return args[1].slice(0, index);
@@ -90,8 +86,7 @@ function getFileArgs(currentWorkingDirectory, fsItems) {
9086
}
9187

9288
//
93-
// ===== Outputting Data =====
94-
89+
// ===== Populating and Outputting Data =====
9590
function populateOutput(currentWorkingDirectory, fsItems, dirArgs, fileArgs) {
9691
let outputString = "";
9792
if (fsItems.length == 1) {
@@ -139,3 +134,7 @@ function print(outputString) {
139134
if (printInList) output = makeList(output);
140135
console.log(output.trimEnd());
141136
}
137+
138+
//
139+
// ===== Run ls =====
140+
ls(process.argv);

0 commit comments

Comments
 (0)