private CommandLine getCommandLine(String[] args) throws ParseException { try { CommandLineParser parser = new GnuParser(); return parser.parse(cmdLineOptions, args); } catch (ParseException e) { printAndExit("HiveSchemaTool:Parsing failed. Reason: " + e.getLocalizedMessage()); return null; } }
line = parser.parse(tool.cmdLineOptions, args); } catch (ParseException e) { System.err.println("UpgradeTool: Parsing failed. Reason: " + e.getLocalizedMessage()); printAndExit(tool); return;
line = parser.parse(tool.cmdLineOptions, args); } catch (ParseException e) { System.err.println("PreUpgradeTool: Parsing failed. Reason: " + e.getLocalizedMessage()); printAndExit(tool); return;
printUsage(e.getLocalizedMessage(), options); } catch (IOException | KeeperException | InterruptedException | ExecutionException e) { throw new IOException(String.format("unable to perform operation: %s", e.getLocalizedMessage()), e);
public static CommandLine getCommandLine(Options options, String[] args){ CommandLineParser parser = new BasicParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException e) { System.err.println("ERROR: " + e.getLocalizedMessage()); printUsage(options); } if (cmd.hasOption("help")) { printUsage(options); } return cmd; }
private static CommandLine parseDefaultCommandLine(String[] args, ConfigMode configMode) throws ConfigurationSetupException { try { if (args == null || args.length == 0) { return new PosixParser().parse(new Options(), new String[0]); } else { Options options = createOptions(configMode); return new PosixParser().parse(options, args); } } catch (ParseException pe) { throw new ConfigurationSetupException(pe.getLocalizedMessage(), pe); } }
private static CommandLine parseDefaultCommandLine(String[] args, ConfigMode configMode) throws ConfigurationSetupException { try { if (args == null || args.length == 0) { return new PosixParser().parse(new Options(), new String[0]); } else { Options options = createOptions(configMode); return new PosixParser().parse(options, args); } } catch (ParseException pe) { throw new ConfigurationSetupException(pe.getLocalizedMessage(), pe); } }
private static CommandLine parseDefaultCommandLine(String[] args, ConfigMode configMode) throws ConfigurationSetupException { try { if (args == null || args.length == 0) { return new PosixParser().parse(new Options(), new String[0]); } else { Options options = createOptions(configMode); return new PosixParser().parse(options, args); } } catch (ParseException pe) { throw new ConfigurationSetupException(pe.getLocalizedMessage(), pe); } }
System.err.println(ex.getLocalizedMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(SwingLauncher.class.getSimpleName(), options);
LOGGER.info( e.getLocalizedMessage() ); CLIManager.displayHelp(); returnCode = RC_BAD_ARG;
/** * Invoke this application with parameters. * * @param parameters * the command options * @return the result of the command * @throws ParseException * if the parameters do not match the configuration */ public static <Value> Value invoke(ObjectFactory executor, String[] parameters) throws Exception, ParseException { if (parameters == null) parameters = new String[] {}; try { CommandLineApplication command = new CommandLineApplication( executor); return (Value) command.getObjectInstance(parameters, null, null, null); } catch (ParseException ex) { throw new ParseException(ex.getLocalizedMessage() + "\n Executor: " + executor); } catch (Exception ex) { throw new IllegalStateException("Could not invoke " + executor + " with parameters " + Arrays.asList(parameters), ex); } }
line = parser.parse(options, args); } catch (ParseException ex) { System.out.println(ex.getLocalizedMessage()); System.out.println(); printUsage();
printUsage(e.getLocalizedMessage(), options); } catch (IOException | KeeperException | InterruptedException | ExecutionException e) { throw new IOException(String.format("unable to perform operation: %s", e.getLocalizedMessage()), e);
line = parser.parse(options, args); } catch (ParseException ex) { System.out.println(ex.getLocalizedMessage()); System.out.println(); printUsage();
throw new IllegalArgumentException(ex.getLocalizedMessage());
System.err.println(ex.getLocalizedMessage()); printUsage(); System.exit(-1);
System.err.println(ex.getLocalizedMessage()); printUsage(); System.exit(-1);
System.err.println(ex.getLocalizedMessage()); printUsage(); System.exit(-1);
parameters)); } catch (ParseException ex) { throw new ParseException(ex.getLocalizedMessage() + "\nOptions were " + Arrays.asList(parameters) + "\n" + getOptionsHelp());
public static void main(String[] args) { DroidefenseScan scan = new DroidefenseScan(args); try { scan.loadUserPreferences(); } catch (UnknownAnalyzerException e) { Log.write(LoggerType.ERROR, "Analyzer not found", e.getLocalizedMessage()); } catch (ParseException e) { Log.write(LoggerType.ERROR, "Parsing exception detected", e.getLocalizedMessage()); } catch (InvalidScanParametersException e) { Log.write(LoggerType.ERROR, "Invalid scan parameter provided", e.getLocalizedMessage()); } catch (EnvironmentNotReadyException e) { Log.write(LoggerType.ERROR, "Environment not ready", e.getBaseMessage()); Log.write(LoggerType.ERROR, "Please, check a valid .json file exists before executing the scan"); scan.createDefaultConfigurationFile(); } }