/** * @deprecated Use {@link CommandLineUtils#translateCommandline(String)} instead. */ public static String[] translateCommandline( String toProcess ) throws Exception { return CommandLineUtils.translateCommandline( toProcess ); }
public void setLine( String line ) { if ( line == null ) { return; } try { parts = CommandLineUtils.translateCommandline( line ); } catch ( Exception e ) { System.err.println( "Error translating Commandline." ); } }
/** * Create a new command line object. Shell is autodetected from operating system Shell usage is only desirable when * generating code for remote execution. * * @param toProcess */ public Commandline( String toProcess, Shell shell ) { this.shell = shell; String[] tmp = new String[0]; try { tmp = CommandLineUtils.translateCommandline( toProcess ); } catch ( Exception e ) { System.err.println( "Error translating Commandline." ); } if ( ( tmp != null ) && ( tmp.length > 0 ) ) { setExecutable( tmp[0] ); for ( int i = 1; i < tmp.length; i++ ) { createArgument().setValue( tmp[i] ); } } }
/** * Create a new command line object, given a command following POSIX sh quoting rules * * @param toProcess */ public Commandline( String toProcess ) { setDefaultShell(); String[] tmp = new String[0]; try { tmp = CommandLineUtils.translateCommandline( toProcess ); } catch ( Exception e ) { System.err.println( "Error translating Commandline." ); } if ( ( tmp != null ) && ( tmp.length > 0 ) ) { setExecutable( tmp[0] ); for ( int i = 1; i < tmp.length; i++ ) { createArgument().setValue( tmp[i] ); } } }
public Builder additionalArgs(String additionalArgs) { try { this.additionalArgs = CommandLineUtils.translateCommandline(additionalArgs); } catch (Exception e) { throw new IllegalArgumentException("Unable to translate additional arguments into command line array", e); } return this; }
private static String[] parseArgs(String arguments) { if (arguments == null || arguments.trim().isEmpty()) { return NO_ARGS; } try { arguments = arguments.replace('\n', ' ').replace('\t', ' '); return CommandLineUtils.translateCommandline(arguments); } catch (Exception ex) { throw new IllegalArgumentException( "Failed to parse arguments [" + arguments + "]", ex); } }
@VisibleForTesting String[] getCommandLineOptions(String commandLineOptions) throws ExecutionException { try { return CommandLineUtils.translateCommandline(commandLineOptions); } catch (Exception e) { throw new ExecutionException(UNABLE_TO_BUILD_CMD_LINE_OPTIONS, e); } } }
/** * Parses the argument string given by the user. Strings are recognized as everything between STRING_WRAPPER. * PARAMETER_DELIMITER is ignored inside a string. STRING_WRAPPER and PARAMETER_DELIMITER can be escaped using * ESCAPE_CHAR. * * @return Array of String representing the arguments * @throws MojoExecutionException for wrong formatted arguments */ protected String[] parseCommandlineArgs() throws MojoExecutionException { if ( commandlineArgs == null ) { return null; } else { try { return CommandLineUtils.translateCommandline( commandlineArgs ); } catch ( Exception e ) { throw new MojoExecutionException( e.getMessage() ); } } }
/** * Parses the argument string given by the user. Strings are recognized as everything between STRING_WRAPPER. * PARAMETER_DELIMITER is ignored inside a string. STRING_WRAPPER and PARAMETER_DELIMITER can be escaped using * ESCAPE_CHAR. * * @return Array of String representing the arguments * @throws MojoExecutionException for wrong formatted arguments */ protected String[] parseCommandlineArgs() throws MojoExecutionException { if ( commandlineArgs == null ) { return null; } else { try { return CommandLineUtils.translateCommandline( commandlineArgs ); } catch ( Exception e ) { throw new MojoExecutionException( e.getMessage() ); } } }
private void handleSystemPropertyArguments( String argsProp, List<String> commandArguments ) throws MojoExecutionException { getLog().debug( "got arguments from system properties: " + argsProp ); try { String[] args = CommandLineUtils.translateCommandline( argsProp ); commandArguments.addAll( Arrays.asList( args ) ); } catch ( Exception e ) { throw new MojoExecutionException( "Couldn't parse systemproperty 'exec.args'" ); } }
private void handleSystemPropertyArguments( String argsProp, List<String> commandArguments ) throws MojoExecutionException { getLog().debug( "got arguments from system properties: " + argsProp ); try { String[] args = CommandLineUtils.translateCommandline( argsProp ); commandArguments.addAll( Arrays.asList( args ) ); } catch ( Exception e ) { throw new MojoExecutionException( "Couldn't parse systemproperty 'exec.args'" ); } }
/** * Executes Maven goals. * * @param goals * The goals to execute. * @throws Exception */ protected void mvnRun(final String goals) throws Exception { getLog().info("Running Maven goals: " + goals); executeMvnCommand(CommandLineUtils.translateCommandline(goals)); }
static Map<String, String> getCustomGlobalUserProperties() { //maybe set org.eclipse.aether.ConfigurationProperties.USER_AGENT with netbeans specific value. Map<String, String> toRet = new HashMap<String, String>(); String options = getPreferences().get(PROP_DEFAULT_OPTIONS, ""); try { String[] cmdlines = CommandLineUtils.translateCommandline(options); if (cmdlines != null) { for (String cmd : cmdlines) { if (cmd != null && cmd.startsWith("-D")) { cmd = cmd.substring("-D".length()); int ind = cmd.indexOf('='); if (ind > -1) { String key = cmd.substring(0, ind); String val = cmd.substring(ind + 1); toRet.put(key, val); } } } } return toRet; } catch (Exception ex) { LOG.log(Level.FINE, "cannot parse " + options, ex); return Collections.emptyMap(); } }
private List<String> getJvmArgs() { List<String> extra = new ArrayList<String>(); String userExtraJvmArgs = getExtraJvmArgs(); if ( userExtraJvmArgs != null ) { try { // cleanup new lines bc removeDuplicateWhitespace leaves the first isWhitespace character found userExtraJvmArgs = userExtraJvmArgs.replace('\n', ' ').replace('\r', ' '); return new ArrayList<String>(Arrays.asList( CommandLineUtils.translateCommandline( StringUtils.removeDuplicateWhitespace( userExtraJvmArgs ) ) ) ); } catch ( Exception e ) { throw new RuntimeException( e ); } } return extra; }
private List<String> getJvmArgs() { List<String> extra = new ArrayList<String>(); String userExtraJvmArgs = getExtraJvmArgs(); if ( userExtraJvmArgs != null ) { try { // cleanup new lines bc removeDuplicateWhitespace leaves the first isWhitespace character found userExtraJvmArgs = userExtraJvmArgs.replace('\n', ' ').replace('\r', ' '); return new ArrayList<String>(Arrays.asList( CommandLineUtils.translateCommandline( StringUtils.removeDuplicateWhitespace( userExtraJvmArgs ) ) ) ); } catch ( Exception e ) { throw new RuntimeException( e ); } } return extra; }
@Override public void execute() throws MojoExecutionException, MojoFailureException { if (optionalRunExtraArgs == null) { optionalRunExtraArgs = new ArrayList<>(); } String runArgsProp = System.getProperty("vertx.runArgs"); if (StringUtils.isNotEmpty(runArgsProp)) { getLog().debug("Got command line arguments from property :" + runArgsProp); try { String[] argValues = CommandLineUtils.translateCommandline(runArgsProp); optionalRunExtraArgs.addAll(Arrays.asList(argValues)); } catch (Exception e) { throw new MojoFailureException("Unable to parse system property vertx.runArgs", e); } } else if (runArgs != null && !runArgs.isEmpty()) { optionalRunExtraArgs.addAll(runArgs); } super.execute(); } }
private int runPerformanceTest(FilePath bztWorkingDirectory, FilePath workspace, PrintStream logger, Launcher launcher, EnvVars envVars, boolean isVirtualenvInstallation) throws InterruptedException, IOException { final List<String> testCommand = new ArrayList<>(); testCommand.add((isVirtualenvInstallation ? getVirtualenvPath(workspace) : "") + PERFORMANCE_TEST_COMMAND); String[] parsedParams; try { parsedParams = CommandLineUtils.translateCommandline(envVars.expand(this.params)); } catch (Exception e) { logger.println("Failed parse Taurus parameters"); e.printStackTrace(logger); return 1; } for (String param : parsedParams) { if (!param.isEmpty()) { testCommand.add(param); } } if (generatePerformanceTrend) { testCommand.add(extractDefaultReportToWorkingDirectory(bztWorkingDirectory)); } logger.println("Performance test: run " + Arrays.toString(testCommand.toArray())); return runCmd(testCommand.toArray(new String[testCommand.size()]), bztWorkingDirectory, logger, launcher, envVars); }
cl.addArguments( CommandLineUtils.translateCommandline( arguments ) );
public static Stream<JsonElement> parseCsv(Reader reader, String optionStr) throws IOException { // Parse options String[] args; try { args = CommandLineUtils.translateCommandline(optionStr); } catch(Exception e) { throw new RuntimeException(e); } OptionParser optionParser = new OptionParser(); OptionSpec<?> rowAsObjectOs = optionParser .acceptsAll(Arrays.asList("o"), "Output rows as objects") ; OptionSpec<?> firstRowAsHeadersOs = optionParser .acceptsAll(Arrays.asList("h"), "First row as headers") ; CsvFormatParser csvFormatParser = new CsvFormatParser(optionParser); OptionSet options = optionParser.parse(args); CSVFormat csvFormat = csvFormatParser.parse(options, CSVFormat.EXCEL); boolean firstRowAsHeaders = options.has(firstRowAsHeadersOs); boolean rowAsObject = options.has(rowAsObjectOs) || firstRowAsHeaders; Stream<JsonElement> result = parseCsv(reader, csvFormat, rowAsObject, firstRowAsHeaders); return result; }
public static Stream<JsonElement> parseCsv(Reader reader, String optionStr) throws IOException { // Parse options String[] args; try { args = CommandLineUtils.translateCommandline(optionStr); } catch(Exception e) { throw new RuntimeException(e); } OptionParser optionParser = new OptionParser(); OptionSpec<?> rowAsObjectOs = optionParser .acceptsAll(Arrays.asList("o"), "Output rows as objects") ; OptionSpec<?> firstRowAsHeadersOs = optionParser .acceptsAll(Arrays.asList("h"), "First row as headers") ; CsvFormatParser csvFormatParser = new CsvFormatParser(optionParser); OptionSet options = optionParser.parse(args); CSVFormat csvFormat = csvFormatParser.parse(options, CSVFormat.EXCEL); boolean firstRowAsHeaders = options.has(firstRowAsHeadersOs); boolean rowAsObject = options.has(rowAsObjectOs) || firstRowAsHeaders; Stream<JsonElement> result = parseCsv(reader, csvFormat, rowAsObject, firstRowAsHeaders); return result; }