热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.codehaus.plexus.util.cli.Commandline类的使用及代码示例

本文整理了Java中org.codehaus.plexus.util.cli.Commandline类的一些代码示例,展示了Commandline

本文整理了Java中org.codehaus.plexus.util.cli.Commandline类的一些代码示例,展示了Commandline类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Commandline类的具体详情如下:
包路径:org.codehaus.plexus.util.cli.Commandline
类名称:Commandline

Commandline介绍

[英]Commandline objects help handling command lines specifying processes to execute.

The class can be used to define a command line as nested elements or as a helper to define a command line by an application.
                    

The element someelement must provide a method createAcommandline which returns an instance of this class.
[中]命令行对象有助于处理指定要执行的进程的命令行。
该类可用于将命令行定义为嵌套元素,也可用于帮助应用程序定义命令行。
                    
元素someelement必须提供返回此类实例的方法createAcommandline

代码示例

代码示例来源:origin: simpligility/android-maven-plugin

commandline = new Commandline();
if ( customShell != null )
commandline.setShell( customShell );
commandline.setExecutable( executable );
commandline.addEnvironment( entry.getKey(), entry.getValue() );
commandline.addArguments( commands.toArray( new String[ commands.size() ] ) );
if ( workingDirectory != null && workingDirectory.exists() )
commandline.setWorkingDirectory( workingDirectory.getAbsolutePath() );
result = CommandLineUtils.executeCommandLine( commandline, stdOut, stdErr );
if ( logger != null )
+ commandline.toString() + ", Result = " + result );
+ commandline.toString() + ", Error message = " + e.getMessage() );
setPid( commandline.getPid() );

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
*

Creates an argument object.


*
*

Each commandline object has at most one instance of the argument class. This method calls
* this.createArgument(false).


*
* @return the argument object.
* @see #createArgument(boolean)
*/
public Arg createArg()
{
return this.createArg( false );
}

代码示例来源:origin: org.codehaus.plexus/plexus-utils

public Object clone()
{
Commandline c = new Commandline( (Shell) shell.clone() );
c.executable = executable;
c.workingDir = workingDir;
c.addArguments( getArguments() );
return c;
}

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
* 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 {
createArgument().setValue( tmp[i] );
}
}
}

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
* 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 {
createArgument().setValue( tmp[i] );
}
}
}

代码示例来源:origin: org.apache.maven.scm/maven-scm-provider-tfs

public static Commandline createCommandLine( File workingDirectory, String filename )
{
Commandline command = new Commandline();
command.setWorkingDirectory( workingDirectory );
command.setExecutable( "tfpt" );
command.createArg().setValue( "annotate" );
command.createArg().setValue( "/noprompt" );
command.createArg().setValue( filename );
return command;
}
}

代码示例来源:origin: apache/maven-scm

public Commandline buildCmdLine( VssScmProviderRepository repo, ScmFileSet fileSet, String tagName, String message )
throws ScmException
{
Commandline command = new Commandline();
command.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() );
try
{
command.addSystemEnvironment();
}
catch ( Exception e )
{
throw new ScmException( "Can't add system environment.", e );
}
command.addEnvironment( "SSDIR", repo.getVssdir() );
String ssDir = VssCommandLineUtils.getSsDir();
command.setExecutable( ssDir + VssConstants.SS_EXE );
command.createArg().setValue( VssConstants.COMMAND_LABEL );
command.createArg().setValue( VssConstants.PROJECT_PREFIX + repo.getProject() );
// User identification to get access to vss repository
if ( repo.getUserPassword() != null )
{
command.createArg().setValue( VssConstants.FLAG_LOGIN + repo.getUserPassword() );
}
// Ignore: Do not ask for input under any circumstances.
command.createArg().setValue( VssConstants.FLAG_AUTORESPONSE_DEF );
command.createArg().setValue( VssConstants.FLAG_LABEL + tagName );
return command;
}

代码示例来源:origin: org.apache.maven.scm/maven-scm-provider-clearcase

public static Commandline createCommandLine( ScmLogger logger, ScmFileSet scmFileSet )
{
Commandline command = new Commandline();
File workingDirectory = scmFileSet.getBasedir();
command.setWorkingDirectory( workingDirectory.getAbsolutePath() );
command.setExecutable( "cleartool" );
command.createArg().setValue( "co" );
command.createArg().setValue( "-nc" );
List files = scmFileSet.getFileList();
for ( File file : files )
{
if ( logger.isInfoEnabled() )
{
logger.info( "edit file: " + file.getAbsolutePath() );
}
command.createArg().setValue( file.getAbsolutePath() );
}
return command;
}

代码示例来源:origin: org.apache.maven.scm/maven-scm-provider-integrity

throws ScmException
Commandline shell = new Commandline();
shell.setWorkingDirectory( workingDirectory.getBasedir() );
shell.setExecutable( "si" );
shell.createArg().setValue( "connect" );
shell.createArg().setValue( "--hostname=" + iRepo.getHost() );
shell.createArg().setValue( "--port=" + iRepo.getPort() );
shell.createArg().setValue( "--user=" + iRepo.getUser() );
shell.createArg().setValue( "--batch" );
shell.createArg().setValue( "--password=" + iRepo.getPassword() );
CommandLineUtils.StringStreamConsumer shellCOnsumer= new CommandLineUtils.StringStreamConsumer();
getLogger().debug( "Executing: " + CommandLineUtils.toString( shell.getCommandline() ) );
int exitCode = CommandLineUtils.executeCommandLine( shell, shellConsumer, shellConsumer );
if ( exitCode != 0 )
throw new ScmException( "Can't login to integrity. Message : " + shellConsumer.toString() );
getLogger().error( "Command Line Connect Exception: " + cle.getMessage() );
throw new ScmException( "Can't login to integrity. Message : " + cle.getMessage() );

代码示例来源:origin: org.apache.maven.scm/maven-scm-provider-cvs

Commandline cl = new Commandline();
cl.setExecutable( "cvs" );
cl.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() );
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 );
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
getLogger().info( "Executing: " + cl );
getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() );
exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr );
throw new ScmException( "Error while executing command.", ex );
return new UpdateScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false );
return new UpdateScmResult( cl.toString(), consumer.getUpdatedFiles() );

代码示例来源:origin: org.apache.maven.scm/maven-scm-provider-git-commons

public static Commandline getBaseCommand( String commandName, GitScmProviderRepository repo, ScmFileSet fileSet,
String options )
{
Settings settings = GitUtil.getSettings();
Commandline cl = new Commandline();
cl.setExecutable( settings.getGitCommand() );
cl.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() );
if ( settings.getTraceGitCommand() != null )
{
cl.addEnvironment( "GIT_TRACE", settings.getTraceGitCommand() );
}
cl.createArg().setLine( options );
cl.createArg().setValue( commandName );
return cl;
}

代码示例来源:origin: org.apache.maven.scm/maven-scm-provider-cvs-commons

public static boolean isCvsNT()
throws ScmException
{
Commandline cl = new Commandline();
cl.setExecutable( "cvs" );
cl.createArg().setValue( "-v" );
CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
try
{
CommandLineUtils.executeCommandLine( cl, stdout, stderr );
}
catch ( CommandLineException e )
{
throw new ScmException( "Error while executing command.", e );
}
return stdout.getOutput().indexOf( "CVSNT" ) >= 0;
}

代码示例来源:origin: simpligility/android-maven-plugin

Commandline cli = new Commandline();
cli.setWorkingDirectory( workingDirectory.getAbsolutePath() );
cli.setExecutable( executable );
cli.addArguments( args );
returnCode = CommandLineUtils.executeCommandLine( cli, out, err );

代码示例来源:origin: jenkinsci/scm-sync-configuration-plugin

public static Commandline createSpecificPushCommandLine(ScmLogger logger, GitScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version)
throws ScmException {
Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "push");
String branch = GitBranchCommand.getCurrentBranch(logger, repository, fileSet);
if (branch == null || branch.length() == 0) {
throw new ScmException("Could not detect the current branch. Don't know where I should push to!");
}
// Overloaded branch name here : if repository.getUrl() is kept, during checkin(), current *local* branch
// reference is not updated, whereas by using origin, it will be done !
cl.createArg().setValue("origin");
cl.createArg().setValue(branch + ":" + branch);
return cl;
}

代码示例来源:origin: org.apache.maven.scm/maven-scm-provider-starteam

/** {@inheritDoc} */
protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet )
throws ScmException
{
if ( getLogger().isInfoEnabled() )
{
getLogger().info( "Working directory: " + fileSet.getBasedir().getAbsolutePath() );
}
if ( fileSet.getFileList().size() != 0 )
{
throw new ScmException( "This provider doesn't support checking status of a subsets of a directory" );
}
StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo;
StarteamStatusConsumer cOnsumer= new StarteamStatusConsumer( getLogger(), fileSet.getBasedir() );
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
Commandline cl = createCommandLine( repository, fileSet );
int exitCode = StarteamCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() );
if ( exitCode != 0 )
{
return new StatusScmResult( cl.toString(), "The starteam command failed.", stderr.getOutput(), false );
}
return new StatusScmResult( cl.toString(), consumer.getChangedFiles() );
}

代码示例来源:origin: org.apache.maven.scm/maven-scm-provider-cvs

protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet )
throws ScmException
{
Commandline cl = createCommandLine( fileSet );
CvsStatusConsumer cOnsumer= new CvsStatusConsumer( getLogger(), fileSet.getBasedir() );
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
getLogger().info( "Executing: " + cl );
getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() );
int exitCode;
getLogger().debug( "Working directory: " + fileSet.getBasedir().getAbsolutePath() );
getLogger().debug( "Command line: " + cl );

try
{
exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr );
}
catch ( CommandLineException ex )
{
throw new ScmException( "Error while executing command.", ex );
}
if ( exitCode != 0 )
{
return new StatusScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false );
}
return new StatusScmResult( cl.toString(), consumer.getChangedFiles() );
}

代码示例来源:origin: org.kuali.common/kuali-core

private Commandline getCommandLine(ExecRequest request) {
Commandline cl = new Commandline();
if (request.getShell().isPresent()) {
cl.getShell().setShellCommand(request.getShell().get());
}
cl.setExecutable(request.getExecutable());
cl.addArguments(request.getArgs().toArray(EMPTY_STRING_ARRAY));
if (request.getWorkingDirectory().isPresent()) {
cl.setWorkingDirectory(request.getWorkingDirectory().get());
}
addSystemEnvironmentVariables(cl, request.isAddSystemEnvironmentVariables());
// Explicit environment variables "win" over system environment variables
for (Map.Entry pair : request.getEnvironmentVariables().entrySet()) {
cl.addEnvironment(pair.getKey(), pair.getValue());
}
return cl;
}

代码示例来源:origin: apache/maven-scm

private static Commandline buildPythonCmd( File workingDir, String[] cmdAndArgs )
throws ScmException
{
Commandline cmd = new Commandline();
cmd.setExecutable( PYTHON_EXEC );
cmd.setWorkingDirectory( workingDir.getAbsolutePath() );
cmd.addArguments( cmdAndArgs );
if ( !workingDir.exists() )
{
boolean success = workingDir.mkdirs();
if ( !success )
{
String msg = "Working directory did not exist" + " and it couldn't be created: " + workingDir;
throw new ScmException( msg );
}
}
return cmd;
}

代码示例来源:origin: org.apache.maven.scm/maven-scm-provider-cvs-commons

/** {@inheritDoc} */
protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet )
throws ScmException
{
CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
Commandline cl = CvsCommandUtils.getBaseCommand( "update", repository, fileSet, "-n" );
cl.createArg().setValue( "-d" );
if ( getLogger().isInfoEnabled() )
{
getLogger().info( "Executing: " + cl );
getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() );
}
return executeCvsCommand( cl );
}

代码示例来源:origin: org.kuali.common/kuali-util

protected Commandline getCommandLine(ExecContext context) {
Commandline cl = new Commandline();
cl.setExecutable(context.getExecutable());
if (context.isAddSystemEnvironment()) {
try {
cl.addSystemEnvironment();
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
if (context.getArgs() != null) {
cl.addArguments(CollectionUtils.toStringArray(context.getArgs()));
}
if (context.getWorkingDirectory() != null) {
cl.setWorkingDirectory(context.getWorkingDirectory());
}
return cl;
}

推荐阅读
  • 本文介绍了Java调用Windows下某些程序的方法,包括调用可执行程序和批处理命令。针对Java不支持直接调用批处理文件的问题,提供了一种将批处理文件转换为可执行文件的解决方案。介绍了使用Quick Batch File Compiler将批处理脚本编译为EXE文件,并通过Java调用可执行文件的方法。详细介绍了编译和反编译的步骤,以及调用方法的示例代码。 ... [详细]
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • Go Cobra命令行工具入门教程
    本文介绍了Go语言实现的命令行工具Cobra的基本概念、安装方法和入门实践。Cobra被广泛应用于各种项目中,如Kubernetes、Hugo和Github CLI等。通过使用Cobra,我们可以快速创建命令行工具,适用于写测试脚本和各种服务的Admin CLI。文章还通过一个简单的demo演示了Cobra的使用方法。 ... [详细]
  • 使用C++编写程序实现增加或删除桌面的右键列表项
    本文介绍了使用C++编写程序实现增加或删除桌面的右键列表项的方法。首先通过操作注册表来实现增加或删除右键列表项的目的,然后使用管理注册表的函数来编写程序。文章详细介绍了使用的五种函数:RegCreateKey、RegSetValueEx、RegOpenKeyEx、RegDeleteKey和RegCloseKey,并给出了增加一项的函数写法。通过本文的方法,可以方便地自定义桌面的右键列表项。 ... [详细]
  • 本文整理了Java中java.lang.NoSuchMethodError.getMessage()方法的一些代码示例,展示了NoSuchMethodErr ... [详细]
  • 本文介绍了使用readlink命令获取文件的完整路径的简单方法,并提供了一个示例命令来打印文件的完整路径。共有28种解决方案可供选择。 ... [详细]
  • 本文整理了Java中org.gwtbootstrap3.client.ui.Icon.addDomHandler()方法的一些代码示例,展示了Icon.ad ... [详细]
  • location,locationManager
    https:stackoverflow.comsearch?tabvotes&q[android]locationisnullhttps:developer.android.go ... [详细]
  • 本文整理了Java中org.apache.pig.backend.executionengine.ExecException.<init>()方法的一些代码 ... [详细]
  • 本文讨论了如何优化解决hdu 1003 java题目的动态规划方法,通过分析加法规则和最大和的性质,提出了一种优化的思路。具体方法是,当从1加到n为负时,即sum(1,n)sum(n,s),可以继续加法计算。同时,还考虑了两种特殊情况:都是负数的情况和有0的情况。最后,通过使用Scanner类来获取输入数据。 ... [详细]
  • 知识图谱——机器大脑中的知识库
    本文介绍了知识图谱在机器大脑中的应用,以及搜索引擎在知识图谱方面的发展。以谷歌知识图谱为例,说明了知识图谱的智能化特点。通过搜索引擎用户可以获取更加智能化的答案,如搜索关键词"Marie Curie",会得到居里夫人的详细信息以及与之相关的历史人物。知识图谱的出现引起了搜索引擎行业的变革,不仅美国的微软必应,中国的百度、搜狗等搜索引擎公司也纷纷推出了自己的知识图谱。 ... [详细]
  • 使用圣杯布局模式实现网站首页的内容布局
    本文介绍了使用圣杯布局模式实现网站首页的内容布局的方法,包括HTML部分代码和实例。同时还提供了公司新闻、最新产品、关于我们、联系我们等页面的布局示例。商品展示区包括了车里子和农家生态土鸡蛋等产品的价格信息。 ... [详细]
  • 本文整理了Java中com.evernote.android.job.JobRequest.getTransientExtras()方法的一些代码示例,展示了 ... [详细]
  • 本文整理了常用的CSS属性及用法,包括背景属性、边框属性、尺寸属性、可伸缩框属性、字体属性和文本属性等,方便开发者查阅和使用。 ... [详细]
author-avatar
重羽玉婷018
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有