當前位置: 首頁>>代碼示例>>Java>>正文


Java MissingArgumentException類代碼示例

本文整理匯總了Java中org.apache.commons.cli.MissingArgumentException的典型用法代碼示例。如果您正苦於以下問題:Java MissingArgumentException類的具體用法?Java MissingArgumentException怎麽用?Java MissingArgumentException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MissingArgumentException類屬於org.apache.commons.cli包,在下文中一共展示了MissingArgumentException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleCommonOption

import org.apache.commons.cli.MissingArgumentException; //導入依賴的package包/類
protected boolean handleCommonOption(final GfxdOption opt, final String cmd,
    final String cmdDescKey) throws ParseException {
  if (SYSTEM_PROPERTY.equals(opt.getOpt())) {
    String optValue = opt.getValue();
    int indexOfEquals = optValue.indexOf('=');
    if (indexOfEquals >= 0) {
      System.setProperty(optValue.substring(0, indexOfEquals),
          optValue.substring(indexOfEquals + 1));
    }
    else {
      throw new MissingArgumentException(opt);
    }
  }
  else if (HELP.equals(opt.getOpt())) {
    showUsage(null, cmd, cmdDescKey);
    throw new GemFireTerminateError(null, 0);
  }
  else {
    return false;
  }
  return true;
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:23,代碼來源:ToolsBase.java

示例2: process

import org.apache.commons.cli.MissingArgumentException; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public static String process(ParseException e) {
    if (e instanceof MissingOptionException) {
        StringBuilder sb = new StringBuilder();
        Iterator<String> options = ((MissingOptionException) e).getMissingOptions().iterator();
        while (options.hasNext()) {
            sb.append(options.next());
            if (options.hasNext()) {
                sb.append(", ");
            }
        }
        return String.format("Missing required option(s) %s.", sb.toString());
    }
    else if (e instanceof MissingArgumentException) {
        return String.format("%s is missing a required argument.",
                ((MissingArgumentException) e).getOption());
    }
    else if (e instanceof UnrecognizedOptionException) {
        return String.format("%s is not a valid option.",
                ((UnrecognizedOptionException) e).getOption());
    }
    else {
        return String.format("%s.", e.getMessage());
    }
}
 
開發者ID:atomist-attic,項目名稱:rug-cli,代碼行數:26,代碼來源:ParseExceptionProcessor.java

示例3: main

import org.apache.commons.cli.MissingArgumentException; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    GraphLoader gl = new GraphLoader();
    Graph<String, UserNodeValues, UserEdgeValues> graph;
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    if(args.length == 0) {
        // read graph from accumulo
        graph = null; // TODO : adapt to gl.getUserGraph();
    } else if (args.length == 1) {
        graph = gl.getUserGraphFromFiles(args[0],env);
    } else {
        throw new MissingArgumentException("Either use no arguments for graph import from accumulo or the path " +
                "to file where the graph is stored.");
    }

    ConnectionAnalysis ca = new ConnectionAnalysis();
    ca.analyze(graph);
}
 
開發者ID:IIDP,項目名稱:OSTMap,代碼行數:18,代碼來源:ConnectionAnalysis.java

示例4: handleReplaceLabelsOnNodes

import org.apache.commons.cli.MissingArgumentException; //導入依賴的package包/類
private int handleReplaceLabelsOnNodes(String[] args, String cmd,
    boolean isHAEnabled) throws IOException, YarnException, ParseException {
  Options opts = new Options();
  opts.addOption("replaceLabelsOnNode", true,
      "Replace label on node.");
  opts.addOption("failOnUnknownNodes", false,
      "Fail on unknown nodes.");
  opts.addOption("directlyAccessNodeLabelStore", false,
      "Directly access node label store.");
  int exitCode = -1;
  CommandLine cliParser = null;
  try {
    cliParser = new GnuParser().parse(opts, args);
  } catch (MissingArgumentException ex) {
    System.err.println(NO_MAPPING_ERR_MSG);
    printUsage(args[0], isHAEnabled);
    return exitCode;
  }

  Map<NodeId, Set<String>> map = buildNodeLabelsMapFromStr(
      cliParser.getOptionValue("replaceLabelsOnNode"));
  return replaceLabelsOnNodes(map,
      cliParser.hasOption("failOnUnknownNodes"),
      cliParser.hasOption("directlyAccessNodeLabelStore"));
}
 
開發者ID:hopshadoop,項目名稱:hops,代碼行數:26,代碼來源:RMAdminCLI.java

示例5: registerAddOn

import org.apache.commons.cli.MissingArgumentException; //導入依賴的package包/類
/**
 * Registers an addOn with the AddOnInformationManager by extracting all relevant information from the addOn and
 * adding it the the sets.
 *
 * Once an addOn is registered, its public data can be viewed by any other addOn through the context.
 *
 * @param addOn The addOn to register with the AddOnInformationManager.
 */
public void registerAddOn(AddOnModel addOn) {
    PluginDescriptor descriptor = addOn.getPlugin().getDescriptor();

    String name = descriptor.getTitle();
    String version = descriptor.getVersion().toString();
    String provider = descriptor.getProvider();
    String id = descriptor.getPluginId();
    String sdkVersion = descriptor.getSdkVersion().toString();
    String artifactID = descriptor.getArtifactID();
    Optional<Integer> serverID = descriptor.getServerID();

    try {
        AddOnInformation addOnInformation = new AddOnInformationImpl(name, provider, version, id, sdkVersion,
                serverID, artifactID);
        addOnInformations.add(addOnInformation);
        addOns.add(addOn);
    } catch (MissingArgumentException e) {
        error("Unable to register addOn: " + addOn.getID() + " with the AddOnInformationManager", e);
    }
}
 
開發者ID:intellimate,項目名稱:Izou,代碼行數:29,代碼來源:AddOnInformationManager.java

示例6: AddOnInformationImpl

import org.apache.commons.cli.MissingArgumentException; //導入依賴的package包/類
/**
 * Creates a new instance of AddOnInformation, which holds all the public information of an addOn and is registered
 * in the {@link AddOnInformationManager} with the serverID.
 *
 * @param name The name of the AddOn.
 * @param version The version of the AddOn.
 * @param provider The author of the AddOn.
 * @param id The unique ID of the AddOn.
 * @param sdkVersion The version of the SDK that this addOn uses.
 * @param serverID The serverID of the addOn, if it has one (used to match the addOn with the server).
 * @param artifactID The artifactID of the addOn. This is the maven artifactID.
 *
 * @throws MissingArgumentException Thrown if the config file of an addon is not complete, in other words if
 * an argument is missing in the file
 */
public AddOnInformationImpl(String name, String provider, String version, String id, String sdkVersion,
                            Optional<Integer> serverID, String artifactID) throws MissingArgumentException {

    if (!checkField(name) || !checkField(provider) || !checkField(version) || !checkField(id)
            || !checkField(sdkVersion) || !checkField(artifactID)) {
        throw new MissingArgumentException("AddOnInformation is not complete - an argument is missing");
    }

    this.name = name;
    this.version = new Version(version);
    this.provider = provider;
    this.id = id;
    this.sdkVersion = new Version(sdkVersion);
    this.serverID = serverID;
    this.artifactID = artifactID;
}
 
開發者ID:intellimate,項目名稱:Izou,代碼行數:32,代碼來源:AddOnInformationImpl.java

示例7: invoke

import org.apache.commons.cli.MissingArgumentException; //導入依賴的package包/類
@Override
public void invoke(FacadeFactory factory, ProjectAndEnv projectAndEnv, Collection<Parameter> cfnParams,
                   Collection<Parameter> artifacts, String... argument) throws IOException, InterruptedException,
        CfnAssistException, MissingArgumentException {
    AwsFacade facade = factory.createFacade();

    String filename;
    if (argument==null) {
        String home = System.getenv("HOME");
        String keypairName = format("%s_%s", projectAndEnv.getProject(), projectAndEnv.getEnv());
        filename = format("%s/.ssh/%s.pem", home, keypairName);
    } else {
        filename = argument[0];
    }

    KeyPair keyPair = facade.createKeyPair(projectAndEnv, factory.getSavesFile(), filename);
    System.out.println(format("Created key %s with fingerprint %s", keyPair.getKeyName(),
            keyPair.getKeyFingerprint()));
}
 
開發者ID:cartwrightian,項目名稱:cfnassist,代碼行數:20,代碼來源:CreateKeyPairAction.java

示例8: parseCli

import org.apache.commons.cli.MissingArgumentException; //導入依賴的package包/類
public static CommandLine parseCli(ModeType mode, String[] args) {
	CommandLine cli = null;
	Options opt = ConfigModes.getMode(mode);
	try {
		cli = new IgnorePosixParser(true).parse(opt, args);
	} catch (MissingArgumentException me) {
		Formatter.usageError(me.getLocalizedMessage(), mode);
		System.exit(-1);
	} catch (MissingOptionException mo) {
		Formatter.usageError(mo.getLocalizedMessage(), mode);
		System.exit(-1);
	} catch (AlreadySelectedException ase) {
		Formatter.usageError(ase.getLocalizedMessage(), mode);
	} catch (UnrecognizedOptionException uoe) {
		Formatter.usageError(uoe.getLocalizedMessage(), mode);
	} catch (ParseException e) {
		Formatter.printStackTrace(e);
		System.exit(-1);
	}

	return cli;
}
 
開發者ID:cyso,項目名稱:vcloud-client,代碼行數:23,代碼來源:Configuration.java

示例9: execute

import org.apache.commons.cli.MissingArgumentException; //導入依賴的package包/類
@Override
public void execute(FacadeFactory factory, ProjectAndEnv projectAndEnv,
		Collection<Parameter> cfnParams, Collection<Parameter> artifacts)
		throws IOException, InterruptedException,
		CfnAssistException, CommandLineException, MissingArgumentException {
	String path = target.getAbsolutePath();

	if (!target.isDirectory()) {
		throw new BuildException(
				String.format("Target %s was not a directory, please provide a directory for the diagrams to be saved into", path));
	}
	
	CreateDiagramAction action = new CreateDiagramAction();
	
	action.validate(projectAndEnv, cfnParams, artifacts, path);
	action.invoke(factory, projectAndEnv, cfnParams, artifacts, path);

}
 
開發者ID:cartwrightian,項目名稱:cfnassist,代碼行數:19,代碼來源:DiagramsElement.java

示例10: execute

import org.apache.commons.cli.MissingArgumentException; //導入依賴的package包/類
@Override
public void execute(FacadeFactory factory, ProjectAndEnv projectAndEnv, Collection<Parameter> cfnParams, Collection<Parameter> artifacts) 
		throws IOException, InterruptedException, CfnAssistException,
		CommandLineException, MissingArgumentException {
	String absolutePath = target.getAbsolutePath();
	CommandLineAction actionToInvoke = null;
	if (target.isDirectory()) {
		actionToInvoke = new DirAction();
	} else if (target.isFile()) {
		actionToInvoke = new FileAction();
	} 
	
	if (actionToInvoke==null) {
		throw new BuildException("Unable to action on path, expect file or folder, path was: " + absolutePath);
	} 
	actionToInvoke.validate(projectAndEnv, cfnParams, artifacts, absolutePath);
	actionToInvoke.invoke(factory, projectAndEnv, cfnParams, artifacts, absolutePath);		
}
 
開發者ID:cartwrightian,項目名稱:cfnassist,代碼行數:19,代碼來源:TemplatesElement.java

示例11: init

import org.apache.commons.cli.MissingArgumentException; //導入依賴的package包/類
@Override
public void init() throws MissingArgumentException, FailedToCreateQueueException, InterruptedException {
	if (init) {
		logger.warn("SNSMonitor init called again");
		return;
	}
	logger.info("Init SNSMonitor");
	topicSnsArn = getOrCreateSNSARN();
	queueURL = getOrCreateQueue();
	
	Map<String, String> queueAttributes = getQueueAttributes(queueURL);
	queueArn = queueAttributes.get(QUEUE_ARN_KEY);
	checkOrCreateQueuePermissions(queueAttributes, topicSnsArn, queueArn, queueURL);
	
	createOrGetSQSSubscriptionToSNS();
	init = true;
}
 
開發者ID:cartwrightian,項目名稱:cfnassist,代碼行數:18,代碼來源:SNSEventSource.java

示例12: createFacade

import org.apache.commons.cli.MissingArgumentException; //導入依賴的package包/類
public AwsFacade createFacade() throws MissingArgumentException, CfnAssistException, InterruptedException {		
	if (awsFacade==null) {
		init();
		SNSEventSource eventSource = new SNSEventSource(snsClient, sqsClient);
		MonitorStackEvents monitor;
		if (snsMonitoring) {	
			monitor = new SNSMonitor(eventSource, cfnRepository);
		} else {
			monitor = new PollingStackMonitor(cfnRepository);
		}
		
		monitor.init();
           AwsRegionProvider regionProvider = new DefaultAwsRegionProviderChain();
           awsFacade = new AwsFacade(monitor, cfnRepository, vpcRepository, elbRepository,
				cloudRepository, notificationSender, identityProvider);
	}	
	return awsFacade;	
}
 
開發者ID:cartwrightian,項目名稱:cfnassist,代碼行數:19,代碼來源:FacadeFactory.java

示例13: shouldCreateSNSAndSQSPlusPolicyAsNeeded

import org.apache.commons.cli.MissingArgumentException; //導入依賴的package包/類
@Test
public void shouldCreateSNSAndSQSPlusPolicyAsNeeded() throws MissingArgumentException, NotReadyException, FailedToCreateQueueException, InterruptedException {
	eventSource.init();
	String existingSNSARN = eventSource.getSNSArn();
	
	// reset the queue, sns and subscription (this forces policy recreation as well)
	String sub = eventSource.getARNofSQSSubscriptionToSNS();
	if (sub!=null) {
		snsClient.unsubscribe(sub);
	}
	snsClient.deleteTopic(existingSNSARN);
	sqsClient.deleteQueue(eventSource.getQueueURL());
	
	// now recreate the source and make sure we can send/receive
	SNSEventSource anotherEventSource = new SNSEventSource(snsClient, sqsClient);
	anotherEventSource.init();
	// should be able to send via sns and then receive from sqs if everything worked ok
	snsClient.publish(anotherEventSource.getSNSArn(), "aMessage");
	ReceiveMessageRequest request = new ReceiveMessageRequest().
			withQueueUrl(anotherEventSource.getQueueURL()).
			withWaitTimeSeconds(10);
	ReceiveMessageResult result = sqsClient.receiveMessage(request);
	assertTrue(result.getMessages().size()>0);
}
 
開發者ID:cartwrightian,項目名稱:cfnassist,代碼行數:25,代碼來源:TestSNSEventSource.java

示例14: shouldThrowWhenExpectedStatusNotWithinTimeout

import org.apache.commons.cli.MissingArgumentException; //導入依賴的package包/類
@Test 
public void shouldThrowWhenExpectedStatusNotWithinTimeout() throws MissingArgumentException, InterruptedException, CfnAssistException {
	isStackFound= true;
	String inProgress = StackStatus.CREATE_IN_PROGRESS.toString();
	
	setExpectationsForInitAndReady();
	setExpectationsRepondInProgressUntilLimit(inProgress);
		
	replayAll();
	monitor.init();
	try {
		monitor.waitForRollbackComplete(stackNameAndId);
		fail("should have thrown");
	}
	catch(WrongStackStatus expectedException) {
		// noop
	}
	verifyAll();
}
 
開發者ID:cartwrightian,項目名稱:cfnassist,代碼行數:20,代碼來源:TestSNSStackMonitor.java

示例15: shouldMonitorMultiplePendingDeletes

import org.apache.commons.cli.MissingArgumentException; //導入依賴的package包/類
@Test
public void shouldMonitorMultiplePendingDeletes() throws InterruptedException, CfnAssistException, MissingArgumentException {
	isStackFound = true;
	String targetStatus = StackStatus.DELETE_COMPLETE.toString();
	
	DeletionsPending pending = createPendingDelete();
	
	eventSource.init();
	EasyMock.expectLastCall();
	EasyMock.expect(eventSource.isInit()).andReturn(true);
	setEventStreamExpectations(StackStatus.DELETE_IN_PROGRESS.toString(), targetStatus, "stackC", "id3");
	setEventStreamExpectations(StackStatus.DELETE_IN_PROGRESS.toString(), targetStatus, "stackB", "id2");
	setEventStreamExpectations(StackStatus.DELETE_IN_PROGRESS.toString(), targetStatus, "stackA", "id1");

	replayAll();
	monitor.init();
	monitor.waitForDeleteFinished(pending, this);
	assertEquals(0, deltaIndexResult);
	verifyAll();
}
 
開發者ID:cartwrightian,項目名稱:cfnassist,代碼行數:21,代碼來源:TestSNSStackMonitor.java


注:本文中的org.apache.commons.cli.MissingArgumentException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。