private static void printMissingInputFileHelp(PrintStream ps) { ps.println( "Specifyed " + inputFileOpt.getArgDescription() + " : \"" + inputFileOpt.getValue(cmdLine) + "\" is not valid !"); ps.println(); printHelp(ps); }
/** * @param args * @throws InvalidCommandLineException */ public void run(String[] args) { int dot = args[0].lastIndexOf(java.io.File.pathSeparatorChar); if (dot == -1) { executableOpt = new CmdArgument( ID_PREFIX + "Executable", null, "executable", "The path of the compiler executable, or simply its name if it ", "EXECUTABLE", null, false); } else { executableOpt = new CmdArgument( ID_PREFIX + "Executable", args[0].substring(+1, args[0].length()), "executable", "The path of the compiler executable, or simply its name if it ", "EXECUTABLE", null, false); } options.addOptions( executableOpt, helpOpt, preprocessOpt, compileOpt, inputFileOpt, outputFileOpt, flagsOpt, defineOpt, includeDirOpt, preIncludeFileOpt, dependencyFileOpt); try { cmdLine = CommandLine.parseArgs(options, false, args); } catch (InvalidCommandLineException e) { System.out.println(e.getMessage()); System.out.println(); printHelp(System.out); System.exit(-1); } // If help is asked, print it and exit. if (helpOpt.isPresent(cmdLine)) { printHelp(System.out); System.exit(0); } // If two actions are specified exit. if (compileOpt.isPresent(cmdLine) && preprocessOpt.isPresent(cmdLine)) { printActionHelp(System.out); System.exit(-1); } // If no action are specified exit. if (!compileOpt.isPresent(cmdLine) && !preprocessOpt.isPresent(cmdLine)) { printActionHelp(System.out); System.exit(-1); } if (!inputFileOpt.isPresent(cmdLine)) { printInputHelp(System.out); System.exit(-1); } if (!outputFileOpt.isPresent(cmdLine)) { printOutputHelp(System.out); System.exit(-1); } if (!(new File(inputFileOpt.getValue(cmdLine))).isFile()) { printMissingInputFileHelp(System.out); System.exit(-1); } if (preprocessOpt.isPresent(cmdLine)) { executor.preprocess(cmdLine); System.exit(0); } if (dependencyFileOpt.isPresent(cmdLine)) { printDependencyWhileCompilingHelp(System.out); System.exit(-1); } if (compileOpt.isPresent(cmdLine)) { executor.compile(cmdLine); System.exit(0); } }