package com.dw.lib.test;

import com.dw.lib.EnvironmentHelper;
import com.dw.lib.FileUtils;

public class WhereCLI {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {
			if (args.length != 1){
				System.out.println("UUID didn't take any arguements");
				return;
			}
			
			String path = EnvironmentHelper.getEnv("PATH");
			String[] paths = path.split(":");
			String executeFile = args[0];
			FileUtils utils = new FileUtils();
			String pathSplitter = EnvironmentHelper.getOSType() == EnvironmentHelper.OSType.WIN? "\\": "/";
			
			for(String p : paths) {
				if(p.endsWith(pathSplitter)) {
					p = p.substring(0, p.length() - 2);
				}
				String tempFullPath = p + pathSplitter + executeFile;
				if(utils.isExisted(tempFullPath)) {
					System.out.println(tempFullPath);
				}
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}

@@ -252,39 +252,102 @@
 ln(%22
-UUID didn't take any arguements
+List all execute file within PATH environment%22);%0A%09%09%09%09System.out.println(%22jwhere %3Cexecute file%3E
 %22);%0A

update WhereCLI