/** * <p>Creates an argument object.</p> * * <p>Each commandline object has at most one instance of the argument class. This method calls * <code>this.createArgument(false)</code>.</p> * * @return the argument object. * @see #createArgument(boolean) * @deprecated Use {@link Commandline#createArg()} instead */ public Argument createArgument() { return this.createArgument( false ); }
public void addArguments( String[] line ) { for ( String aLine : line ) { createArgument().setValue( aLine ); } }
/** * 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 Commandline createCommandLine( ScmFileSet fileSet ) throws ScmException { Commandline cl = new Commandline(); cl.setExecutable( "cvs" ); cl.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() ); cl.createArgument().setValue( "-f" ); // don't use ~/.cvsrc cl.createArgument().setValue( "-n" ); cl.createArgument().setValue( "-q" ); cl.createArgument().setValue( "update" ); cl.createArgument().setValue( "-d" ); return cl; } }
cl.createArgument().setValue( "-q" ); cl.createArgument().setValue( "-f" ); // don't use ~/.cvsrc cl.createArgument().setValue( "diff" ); cl.createArgument().setValue( "-u" ); cl.createArgument().setValue( "-N" ); cl.createArgument().setValue( "-r" ); cl.createArgument().setValue( startRevision ); cl.createArgument().setValue( "-r" ); cl.createArgument().setValue( endRevision );
protected void executable( File file ) throws CommandLineException, IOException { if ( Os.isFamily( "unix" ) ) { Commandline cli = new Commandline(); cli.setExecutable( "chmod" ); cli.createArgument().setValue( "+x" ); cli.createArgument().setValue( file.getAbsolutePath() ); cli.execute(); } }
private synchronized boolean run(String command, String[] args) throws GitException { try { Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workDir, command); if (args != null) { for (int i = 0; i < args.length; i++) cl.createArgument().setValue(args[i]); } StringBuffer sb = new StringBuffer(); sb.append("git ").append(command); if (args != null) { for (int i = 0; i < args.length; i++) sb.append(" ").append(args[i]); } int exitCode = GitCommandLineUtils.execute(cl, stdout, stderr, log); log.debug("RAN: " + sb.toString() + " / $? = " + exitCode); return exitCode == 0; } catch (ScmException e) { throw new GitException("Couldn't run command " + command + ": " + e.getMessage(), e); } }
public ExecutionResult executeShellCommand( File workingDirectory, String executable, String arguments, File output, long idCommand, Map<String, String> environments ) throws Exception { Commandline cl = new Commandline(); Commandline.Argument argument = cl.createArgument(); argument.setLine( arguments ); return executeShellCommand( workingDirectory, executable, argument.getParts(), output, idCommand, environments ); }
public ExecutionResult executeShellCommand( File workingDirectory, String executable, String arguments, File output, long idCommand, Map<String, String> environments ) throws Exception { Commandline cl = new Commandline(); Commandline.Argument argument = cl.createArgument(); argument.setLine( arguments ); return executeShellCommand( workingDirectory, executable, argument.getParts(), output, idCommand, environments ); }
public void executeGoals( File workingDirectory, String executable, String goals, boolean interactive, String arguments, ReleaseResult relResult, Map<String, String> environments ) throws Exception { Commandline cl = new Commandline(); Commandline.Argument argument = cl.createArgument(); argument.setLine( arguments ); executeGoals( workingDirectory, executable, goals, interactive, argument.getParts(), relResult, environments ); }
cl.createArgument().setValue( "-f" ); // don't use ~/.cvsrc cl.createArgument().setValue( "-d" ); cl.createArgument().setValue( repository.getCvsRoot() ); cl.createArgument().setValue( "-q" ); cl.createArgument().setValue( "remove" ); cl.createArgument().setValue( "-f" ); cl.createArgument().setValue( "-l" ); cl.createArgument().setValue( "-m" ); cl.createArgument().setValue( "\"" + message + "\"" ); cl.createArgument().setValue( path ); removedFiles.add( new ScmFile( path, ScmFileStatus.DELETED ) );
cl.createArgument().setValue( "-f" ); // don't use ~/.cvsrc cl.createArgument().setValue( "-d" ); cl.createArgument().setValue( repository.getCvsRoot() ); cl.createArgument().setValue( "-q" ); cl.createArgument().setValue( "checkout" ); cl.createArgument().setValue( "-r" + tag ); cl.createArgument().setValue( "-d" ); cl.createArgument().setValue( fileSet.getBasedir().getName() ); cl.createArgument().setValue( repository.getModule() );
cl.createArgument().setValue( token ); cl.createArgument().setValue( "--no-plugin-updates" ); cl.createArgument().setValue( "--batch-mode" );
cl.createArgument().setValue( "-f" ); // don't use ~/.cvsrc cl.createArgument().setValue( "-d" ); cl.createArgument().setValue( repository.getCvsRoot() ); cl.createArgument().setValue( "-q" ); cl.createArgument().setValue( "tag" ); cl.createArgument().setValue( "-F" ); cl.createArgument().setValue( "-c" ); cl.createArgument().setValue( tag );
cl.createArgument().setValue( argument );
cl.createArgument().setValue( argument );
cmdLine.createArgument().setLine( "rpm" ); cmdLine.createArgument().setLine( "-e" ); cmdLine.createArgument().setLine( "--allmatches" ); cmdLine.createArgument().setLine( rpmPackage ); cmdLine.createArgument().setLine( "--dbpath" ); cmdLine.createArgument().setLine( rpmDbPath );
cl.createArgument().setValue( "-f" ); // don't use ~/.cvsrc cl.createArgument().setValue( "-q" ); cl.createArgument().setValue( "update" ); cl.createArgument().setValue( "-d" ); cl.createArgument().setValue( "-r" + tag );
public String eval( String expression ) throws RpmEvalException { String result = null; Commandline cmdLine = new Commandline(); cmdLine.setExecutable( "rpm" ); cmdLine.createArgument().setLine( "--eval \"%{" + expression + "}\"" ); try { CommandLineUtils.StringStreamConsumer consumer = new CommandLineUtils.StringStreamConsumer(); int exitValue = cliManager.execute( cmdLine, consumer, cliManager.newDebugStreamConsumer() ); if ( exitValue != 0 ) { throw new RpmEvalException( "RPM evaluation exited abnormally for expression: " + expression + "(returned: " + exitValue + ")." ); } result = consumer.getOutput().trim(); } catch ( CommandLineException e ) { throw new RpmEvalException( "Error evaluating RPM expression: " + expression, e ); } return result; }