@@ -26,14 +26,8 @@ function ls(args) {
2626 print ( populateOutput ( currentWorkingDirectory , fsItems , dirArgs , fileArgs ) ) ;
2727}
2828
29- function getFsItems ( userArgs ) {
30- return userArgs . filter ( ( arg ) => ! arg . startsWith ( "-" ) ) ;
31- }
32-
33- function getCurrentWorkingDirectory ( args ) {
34- const index = args [ 1 ] . lastIndexOf ( "/" ) ;
35- return args [ 1 ] . slice ( 0 , index ) ;
36- }
29+ //
30+ // ===== Flag Handling =====
3731
3832function getFlags ( userArgs ) {
3933 return userArgs
@@ -60,10 +54,26 @@ function Flag1() {
6054 printInList = true ;
6155}
6256
57+ function makeList ( outputString ) {
58+ return outputString . replaceAll ( "\t" , "\n" ) . replaceAll ( "\n\n" , "\n" ) ;
59+ }
60+
6361function Flaga ( ) {
6462 showAll = true ;
6563}
6664
65+ //
66+ // ===== Extracting data from arguments =====
67+
68+ function getCurrentWorkingDirectory ( args ) {
69+ const index = args [ 1 ] . lastIndexOf ( "/" ) ;
70+ return args [ 1 ] . slice ( 0 , index ) ;
71+ }
72+
73+ function getFsItems ( userArgs ) {
74+ return userArgs . filter ( ( arg ) => ! arg . startsWith ( "-" ) ) ;
75+ }
76+
6777function checkArgsLength ( fsItems ) {
6878 if ( fsItems . length == 0 ) fsItems . push ( "." ) ;
6979 return fsItems ;
@@ -79,6 +89,9 @@ function getFileArgs(currentWorkingDirectory, fsItems) {
7989 return fileArgs ;
8090}
8191
92+ //
93+ // ===== Outputting Data =====
94+
8295function populateOutput ( currentWorkingDirectory , fsItems , dirArgs , fileArgs ) {
8396 let outputString = "" ;
8497 if ( fsItems . length == 1 ) {
@@ -126,7 +139,3 @@ function print(outputString) {
126139 if ( printInList ) output = makeList ( output ) ;
127140 console . log ( output . trimEnd ( ) ) ;
128141}
129-
130- function makeList ( outputString ) {
131- return outputString . replaceAll ( "\t" , "\n" ) . replaceAll ( "\n\n" , "\n" ) ;
132- }
0 commit comments