package com.dw.lib.cli;

import java.util.List;

import com.dw.lib.FileUtils;

public class CatCLI {

	public static void main(String[] args) {
		try {
			if (args.length < 1){
				System.out.println("jcat to view a text file");
				System.out.println("jcat <text file>");
				return;
			}
			
			FileUtils utils = new FileUtils();
			for(int i=0;i<args.length;i++) {
				System.out.println(args[i] + ":");
				List<String> result = utils.fileToList(args[i]);
				for(String s : result) {
					System.out.println(s);
				}
			}
			
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

}

@@ -251,16 +251,19 @@
 n(%22jcat 
+-l 
 %3Ctext fi
@@ -328,16 +328,46 @@
 tils();%0A
+%09%09%09boolean state = false;%0A%09%09%09%0A
 %09%09%09for(i
@@ -402,124 +402,353 @@
 %09%09%09%09
-System.out.println(args%5Bi%5D + %22:%22);%0A%09%09%09%09List%3CString%3E result = utils.fileToList(args%5Bi%5D);%0A%09%09%09%09for(String s : result) %7B
+boolean showLine = args%5Bi%5D.equals(%22-l%22);%0A%09%09%09%09if (showLine)  %7B%0A%09%09%09%09%09state = true;%0A%09%09%09%09%09continue;%0A%09%09%09%09%7D%0A%09%09%09%09%0A%09%09%09%09System.out.println(args%5Bi%5D + %22:%22);%0A%09%09%09%09List%3CString%3E result = utils.fileToList(args%5Bi%5D);%0A%09%09%09%09int lineNumber = 1;%0A%09%09%09%09%0A%09%09%09%09for(String s : result) %7B%0A%09%09%09%09%09if (state) %7B%0A%09%09%09%09%09%09System.out.print(lineNumber + %22:%5Ct%22);%0A%09%09%09%09%09%09lineNumber++;%0A%09%09%09%09%09%7D
 %0A%09%09%09

add '-l' to show line number for cat