本文整理汇总了Java中com.sampullara.cli.Args类的典型用法代码示例。如果您正苦于以下问题:Java Args类的具体用法?Java Args怎么用?Java Args使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Args类属于com.sampullara.cli包,在下文中一共展示了Args类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import com.sampullara.cli.Args; //导入依赖的package包/类
public <T> T parse(String[] args, T inputArgs, Function<? super T, String> validationFunction) {
try {
List<String> extraArgs = Args.parse(inputArgs, args);
if (extraArgs.size() > 0) {
printUsageAndExit(inputArgs, "Passed in unnecessary args: " + StringUtils.join(extraArgs, "; "));
}
String validationMessage = validationFunction.valueOf(inputArgs);
if (validationMessage != null) {
printUsageAndExit(inputArgs, validationMessage);
}
} catch (IllegalArgumentException exc) {
printUsageAndExit(inputArgs, ExceptionUtils.getStackTrace(exc));
}
LOG.info("Arguments parsed: " + inputArgs.toString());
return inputArgs;
}
示例2: main
import com.sampullara.cli.Args; //导入依赖的package包/类
public static void main( String[] args )
throws Exception
{
Commands command = new Commands();
try
{
Args.parse( command, args );
}
catch ( IllegalArgumentException e )
{
System.err.println( e.getMessage() );
Args.usage( command );
return;
}
ArchivaCli cli = new ArchivaCli();
try
{
cli.execute( command );
}
finally
{
cli.destroy();
}
}
示例3: main
import com.sampullara.cli.Args; //导入依赖的package包/类
public static void main(String[] args) {
Standalone instance = new Standalone();
List<String> projectPaths;
try {
projectPaths = Args.parse(instance, args);
}
catch (Exception e) {
printUsageAndExit();
return;
}
if (projectPaths.isEmpty()) {
System.out.println("Path to project is not specified");
printUsageAndExit();
}
if (projectPaths.size() > 1) {
System.out.println("Only one project can be specified");
printUsageAndExit();
}
final String projectPath = (new File(projectPaths.get(0))).getAbsolutePath();
int exitCode = instance.loadAndRunBuild(FileUtil.toCanonicalPath(projectPath));
System.exit(exitCode);
}
示例4: main
import com.sampullara.cli.Args; //导入依赖的package包/类
public static void main(String[] args) throws IOException
{
CreateLuceneIndexFromDb cr = new CreateLuceneIndexFromDb();
try
{
Args.parse(cr, args);
if (cr.config(args))
{
cr.createIndex();
}
}
catch (IllegalArgumentException e)
{
e.printStackTrace();
Args.usage(cr);
}
}
示例5: main
import com.sampullara.cli.Args; //导入依赖的package包/类
public static void main(String[] args) {
Standalone instance = new Standalone();
List<String> projectPaths;
try {
projectPaths = Args.parse(instance, args);
}
catch (Exception e) {
printUsageAndExit();
return;
}
if (projectPaths.isEmpty()) {
System.out.println("Path to project is not specified");
printUsageAndExit();
}
if (projectPaths.size() > 1) {
System.out.println("Only one project can be specified");
printUsageAndExit();
}
instance.loadAndRunBuild(projectPaths.get(0));
System.exit(0);
}
示例6: main
import com.sampullara.cli.Args; //导入依赖的package包/类
public static void main( String[] args )
throws Exception
{
Commands command = new Commands();
try
{
Args.parse( command, args );
}
catch ( IllegalArgumentException e )
{
LOGGER.error( e.getMessage(), e );
Args.usage( command );
return;
}
ArchivaCli cli = new ArchivaCli();
try
{
cli.execute( command );
}
finally
{
cli.destroy();
}
}
示例7: AndroidPush
import com.sampullara.cli.Args; //导入依赖的package包/类
private AndroidPush(final String[] args) {
try {
Args.parse(this, args, true);
} catch (IllegalArgumentException e) {
System.err.println(e.getMessage());
System.err.println();
Args.usage(this);
System.err.println();
System.err.println("Notes:");
System.err.println(" - If deviceSerial is unset, then commands will be targeted to the only running");
System.err.println(" device. To get a list of running devices and their serial numbers, run");
System.err.println(" 'adb devices'. You can also set the ANDROID_SERIAL environment variable.");
System.err.println(" If you set the java property android.emulator.port, then this will be set");
System.err.println(" to \"emulator-XXX\", unless port is equal to \"device\" (in which case,");
System.err.println(" the only running device will be targetted) or \"emulator\" (in which case,");
System.err.println(" the only running emulator will be targetted)");
System.err.println(" - The options are passed to the executed command as it runs within the shell");
System.exit(1);
throw e;
}
}
示例8: parseArgs
import com.sampullara.cli.Args; //导入依赖的package包/类
void parseArgs(String... args) throws IllegalArgumentException {
List<String> rest = null;
rest = Args.parse(this, args);
if (rest == null || rest.size() != 1) {
//exit("Invalid syntax");
throw new IllegalArgumentException("missing input");
}
if (help){
Args.usage(GenerateMain.class, EXE + "" + SYNTAX);
return;
}
if (target.compareToIgnoreCase("sikuli-java-api")==0){
generator = new JavaAPICodeGenerator(name, new File(imageDir));
}else{
throw new IllegalArgumentException("Unrecognized target: " + target);
}
inputFilename = rest.get(0);
}
示例9: main
import com.sampullara.cli.Args; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
final List<String> parse;
try {
parse = Args.parse(TokenWalletCLI.class, args);
} catch (IllegalArgumentException e) {
Args.usage(TokenWalletCLI.class);
System.exit(1);
return;
}
HDWallet wallet;
if (input != null) {
String seed = new String(Files.readAllBytes(Paths.get(input)));
wallet = new HDWallet().init(seed);
} else {
wallet = new HDWallet().init(null);
}
if (output != null) {
try( PrintWriter out = new PrintWriter( output ) ){
out.println(wallet.getMasterSeed());
}
} else {
System.out.println("Seed: " + wallet.getMasterSeed());
System.out.println("Address: " + wallet.getOwnerAddress());
}
}
示例10: main
import com.sampullara.cli.Args; //导入依赖的package包/类
public static void main(final String[] arguments)
{
final Main instance = new Main();
final List<String> unparsed = Args.parseOrExit(instance, arguments);
if (!unparsed.isEmpty())
{
out.println("Unparsed arguments: " + unparsed);
}
out.println("File path/name is '" + instance.file + "' and verbosity is " + instance.verbose);
}
示例11: execute
import com.sampullara.cli.Args; //导入依赖的package包/类
private void execute( Commands command )
throws Exception
{
if ( command.help )
{
Args.usage( command );
}
else if ( command.version )
{
System.out.print( "Version: " + getVersion() );
}
else if ( command.convert )
{
doConversion( command.properties );
}
else if ( command.scan )
{
if ( command.repository == null )
{
System.err.println( "The repository must be specified." );
Args.usage( command );
return;
}
doScan( command.repository, command.consumers.split( "," ) );
}
else if ( command.listConsumers )
{
dumpAvailableConsumers();
}
else
{
Args.usage( command );
}
}
示例12: printHelpAndExit
import com.sampullara.cli.Args; //导入依赖的package包/类
@Override
public void printHelpAndExit() {
final String[] bannerLines = optionsBanner();
for (String line : bannerLines) {
System.out.println(line);
}
Args.usage(this);
System.exit(1);
}
示例13: main
import com.sampullara.cli.Args; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
CompareItems ci = new CompareItems();
try
{
Args.parse(ci, args);
ci.compare();
}
catch (IllegalArgumentException e)
{
e.printStackTrace();
Args.usage(ci);
}
}
示例14: main
import com.sampullara.cli.Args; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
GetAvgTermFreq g = new GetAvgTermFreq();
try
{
Args.parse(g, args);
g.getDocAvgTermFreqs();
}
catch (IllegalArgumentException e)
{
e.printStackTrace();
Args.usage(g);
}
}
示例15: main
import com.sampullara.cli.Args; //导入依赖的package包/类
/**
* @param args
* @throws InterruptedException
* @throws FileNotFoundException
*/
public static void main(String[] args) throws InterruptedException, FileNotFoundException {
FailFast failFast = new FailFast(Thread.currentThread());
{ // Fail Fast thread
Thread fail_fast_thread = new Thread(failFast);
fail_fast_thread.setName("fail_fast_thread");
fail_fast_thread.start();
}
try
{
Args.parse(ItemAttributesImporter.class, args);
{ // Determine opMode by checking for urlFile
if (urlFile !=null) {
opMode = OperationMode.OPERATION_MODE_FILE_IMPORTER;
}
}
DefaultApiClient client = new DefaultApiClient(apiUrl,consumerKey,consumerSecret,API_TIMEOUT);
ItemAttributesImporter fixer = new ItemAttributesImporter(client);
fixer.setFailFast(failFast);
fixer.run();
}
catch (IllegalArgumentException e)
{
e.printStackTrace();
Args.usage(ItemAttributesImporter.class);
}
}