Package org.apache.commons.cli

Examples of org.apache.commons.cli.MissingArgumentException


        if (!line.isEmpty())
          splits.add(decode ? new Text(Base64.decodeBase64(line.getBytes())) : new Text(line));
      }
    } else {
      if (cl.getArgList().isEmpty())
        throw new MissingArgumentException("No split points specified");
     
      for (String s : cl.getArgs()) {
        splits.add(new Text(s));
      }
    }
View Full Code Here


    ConsoleReader reader = new ConsoleReader();
    try {
      cl = new BasicParser().parse(opts, args);
     
      if (cl.hasOption(zooKeeperInstance.getOpt()) && cl.getOptionValues(zooKeeperInstance.getOpt()).length != 2)
        throw new MissingArgumentException(zooKeeperInstance);
     
      user = cl.getOptionValue(usernameOption.getOpt());
      passw = cl.getOptionValue(passwOption.getOpt());
     
      if (cl.hasOption(zooKeeperInstance.getOpt())) {
View Full Code Here

      shellState.checkTableState();
      tableName = shellState.getTableName();
    }
   
    if (cl.getArgList().isEmpty())
      throw new MissingArgumentException("No terms specified");
   
    // handle first argument, if present, the authorizations list to
    // scan with
    int numThreads = 20;
    if (cl.hasOption(numThreadsOpt.getOpt())) {
View Full Code Here

        @Override
        int runCmd(CommandLine cmdLine) throws Exception {
            String[] args = cmdLine.getArgs();
            if (args.length < 1) {
                throw new MissingArgumentException(
                        "'bookieSrc' argument required");
            }

            ClientConfiguration adminConf = new ClientConfiguration(bkConf);
            BookKeeperAdmin admin = new BookKeeperAdmin(adminConf);
View Full Code Here

  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
   
    final String tableName = OptUtil.getTableOpt(cl, shellState);
   
    if (cl.getArgList().isEmpty()) {
      throw new MissingArgumentException("No terms specified");
    }
    final Class<? extends Formatter> formatter = getFormatter(cl, tableName, shellState);
    final ScanInterpreter interpeter = getInterpreter(cl, tableName, shellState);
   
    // handle first argument, if present, the authorizations list to
View Full Code Here

      setDebugging(cl.hasOption(debugOption.getLongOpt()));
      authTimeout = Integer.parseInt(cl.getOptionValue(authTimeoutOpt.getLongOpt(), DEFAULT_AUTH_TIMEOUT)) * 60 * 1000;
      disableAuthTimeout = cl.hasOption(disableAuthTimeoutOpt.getLongOpt());
     
      if (cl.hasOption(zooKeeperInstance.getOpt()) && cl.getOptionValues(zooKeeperInstance.getOpt()).length != 2)
        throw new MissingArgumentException(zooKeeperInstance);
     
    } catch (Exception e) {
      configError = true;
      printException(e);
      printHelp("shell", SHELL_DESCRIPTION, opts);
      return true;
    }
   
    // get the options that were parsed
    String sysUser = System.getProperty("user.name");
    if (sysUser == null)
      sysUser = "root";
    String user = cl.getOptionValue(usernameOption.getOpt(), sysUser);
   
    String passw = cl.getOptionValue(passwOption.getOpt(), null);
    tabCompletion = !cl.hasOption(tabCompleteOption.getLongOpt());
    String[] loginOptions = cl.getOptionValues(loginOption.getOpt());
   
    // Use a fake (Mock), ZK, or HdfsZK Accumulo instance
    setInstance(cl);
   
    // process default parameters if unspecified
    try {
      if (loginOptions != null && !cl.hasOption(tokenOption.getOpt()))
        throw new IllegalArgumentException("Must supply '-" + tokenOption.getOpt() + "' option with '-" + loginOption.getOpt() + "' option");
     
      if (loginOptions == null && cl.hasOption(tokenOption.getOpt()))
        throw new IllegalArgumentException("Must supply '-" + loginOption.getOpt() + "' option with '-" + tokenOption.getOpt() + "' option");
     
      if (passw != null && cl.hasOption(tokenOption.getOpt()))
        throw new IllegalArgumentException("Can not supply '-" + passwOption.getOpt() + "' option with '-" + tokenOption.getOpt() + "' option");
     
      if (user == null)
        throw new MissingArgumentException(usernameOption);
     
      if (loginOptions != null && cl.hasOption(tokenOption.getOpt())) {
        Properties props = new Properties();
        for (String loginOption : loginOptions)
          for (String lo : loginOption.split(",")) {
            String[] split = lo.split("=");
            props.put(split[0], split[1]);
          }
       
        this.token = Class.forName(cl.getOptionValue(tokenOption.getOpt())).asSubclass(AuthenticationToken.class).newInstance();
        this.token.init(props);
      }
     
      if (!cl.hasOption(fakeOption.getLongOpt())) {
        DistributedTrace.enable(instance, new ZooReader(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut()), "shell", InetAddress.getLocalHost()
            .getHostName());
      }
     
      Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void start() {
          reader.getTerminal().enableEcho();
        }
      });
     
      if (passw != null) {
        this.token = new PasswordToken(passw);
      }
     
      if (this.token == null) {
        passw = readMaskedLine("Password: ", '*');
        if (passw != null)
          this.token = new PasswordToken(passw);
      }
     
      if (this.token == null) {
        reader.printNewline();
        throw new MissingArgumentException("No password or token option supplied");
      } // user canceled
     
      this.setTableName("");
      this.principal = user;
      connector = instance.getConnector(this.principal, token);
View Full Code Here

      setDebugging(cl.hasOption(debugOption.getLongOpt()));
      authTimeout = Integer.parseInt(cl.getOptionValue(authTimeoutOpt.getLongOpt(), DEFAULT_AUTH_TIMEOUT)) * 60 * 1000;
      disableAuthTimeout = cl.hasOption(disableAuthTimeoutOpt.getLongOpt());
     
      if (cl.hasOption(zooKeeperInstance.getOpt()) && cl.getOptionValues(zooKeeperInstance.getOpt()).length != 2)
        throw new MissingArgumentException(zooKeeperInstance);
     
    } catch (Exception e) {
      configError = true;
      printException(e);
      printHelp("shell", SHELL_DESCRIPTION, opts);
      return true;
    }
   
    // get the options that were parsed
    String sysUser = System.getProperty("user.name");
    if (sysUser == null)
      sysUser = "root";
    String user = cl.getOptionValue(usernameOption.getOpt(), sysUser);
   
    String passw = cl.getOptionValue(passwOption.getOpt(), null);
    tabCompletion = !cl.hasOption(tabCompleteOption.getLongOpt());
    String[] loginOptions = cl.getOptionValues(loginOption.getOpt());
   
    // Use a fake (Mock), ZK, or HdfsZK Accumulo instance
    setInstance(cl);
   
    // process default parameters if unspecified
    try {
      if (loginOptions != null && !cl.hasOption(tokenOption.getOpt()))
        throw new IllegalArgumentException("Must supply '-" + tokenOption.getOpt() + "' option with '-" + loginOption.getOpt() + "' option");
     
      if (loginOptions == null && cl.hasOption(tokenOption.getOpt()))
        throw new IllegalArgumentException("Must supply '-" + loginOption.getOpt() + "' option with '-" + tokenOption.getOpt() + "' option");
     
      if (passw != null && cl.hasOption(tokenOption.getOpt()))
        throw new IllegalArgumentException("Can not supply '-" + passwOption.getOpt() + "' option with '-" + tokenOption.getOpt() + "' option");
     
      if (user == null)
        throw new MissingArgumentException(usernameOption);
     
      if (loginOptions != null && cl.hasOption(tokenOption.getOpt())) {
        Properties props = new Properties();
        for (String loginOption : loginOptions)
          for (String lo : loginOption.split(",")) {
            String[] split = lo.split("=");
            props.put(split[0], split[1]);
          }
       
        this.token = Class.forName(cl.getOptionValue(tokenOption.getOpt())).asSubclass(AuthenticationToken.class).newInstance();
        this.token.init(props);
      }
     
      if (!cl.hasOption(fakeOption.getLongOpt())) {
        DistributedTrace.enable(instance, new ZooReader(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut()), "shell", InetAddress.getLocalHost()
            .getHostName());
      }
     
      Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void start() {
          reader.getTerminal().enableEcho();
        }
      });
     
      if (passw != null) {
        this.token = new PasswordToken(passw);
      }
     
      if (this.token == null) {
        passw = readMaskedLine("Password: ", '*');
        if (passw != null)
          this.token = new PasswordToken(passw);
      }
     
      if (this.token == null) {
        reader.printNewline();
        throw new MissingArgumentException("No password or token option supplied");
      } // user canceled
     
      this.setTableName("");
      this.principal = user;
      connector = instance.getConnector(this.principal, token);
View Full Code Here

    private static Locale getLocaleForLanguage(String language) throws MissingArgumentException
    {
        Locale result = localeMap.get(language);
        if (result != null)
            return result;
        throw new MissingArgumentException("Language option must be one of: " + Joiner.on(", ").join(localeMap.keySet()));
    }
View Full Code Here

            }
            else if ("swf".equals(shortName))
            {
                String[] swfValues = option.getValue().split(",");
                if (swfValues.length < 3)
                    throw new MissingArgumentException("The swf option requires three arguments, only " + swfValues.length + " were found.");
               
                for (int j = 0; j < swfValues.length; j++)
                {
                    String value = swfValues[j];
                    if (j == 0)
                        this.setSymbolClass(value);
                    else if (j == 1)
                        this.setWidth(value);
                    else if (j == 2)
                        this.setHeight(value);
                    else if (j == 3)
                        this.setFrameRate(value);
                }
            }
            else if ("use".equals(shortName))
            {
                String[] namespaces = option.getValues();
                for (String namespace : namespaces)
                {
                    this.addNamespace(namespace);
                }
            }
            else if ("config".equals(shortName))
            {
                String[] config = option.getValues();
                if( config.length == 2 )
                {
                    // The config option will have been split around '='
                    // e.g. CONFIG::Foo='hi' will be split into
                    // 2 values - 'CONFIG::Foo' and 'hi'
                    String name = config[0];
                    String value = config[1];
                    value = fixupMissingQuote(value);
                    this.putConfigVar(name, value);
                }
            }
            else if ("strict".equals(shortName) || "!".equals(shortName))
            {
                this.setUseStaticSemantics(true);
            }
            else if ("d".equals(shortName))
            {
                this.setEmitDebugInfo(true);
            }
            else if ("warnings".equals(shortName) || "coach".equals(shortName))
            {
                if ("coach".equals(shortName))
                    err.println("'coach' has been deprecated. Please use 'warnings' instead.");
                this.setShowWarnings(true);
            }
            else if ("log".equals(shortName))
            {
                this.setShowLog(true);
            }
            else if ("md".equals(shortName))
            {
                this.setEmitMetadata(true);
            }
            else if ("merge".equals(shortName))
            {
                this.setMergeABCs(true);
            }
            else if ("language".equals(shortName))
            {
                String value = option.getValue();
                this.setLocale(getLocaleForLanguage(value));
            }
            else if ("doc".equals(shortName))
            {
                this.setEmitDocInfo(true);
            }
            else if ("avmtarget".equals(shortName))
            {
                String value = option.getValue();
                this.setTargetAVM(value);
            }
            else if ("AS3".equals(shortName))
            {
                this.setDialect("AS3");
            }
            else if ("ES".equals(shortName))
            {
                this.setDialect("ES");
            }
            else if ("o".equalsIgnoreCase(shortName) || "optimize".equalsIgnoreCase(shortName))
            {
                this.setOptimize(true);
            }
            else if ("o2".equalsIgnoreCase(shortName))
            {
                this.setOptimize(true);
            }
            else if ("out".equalsIgnoreCase(shortName))
            {
                this.setOutputBasename(option.getValue());
            }
            else if ("outdir".equalsIgnoreCase(shortName))
            {
                this.setOutputDirectory(option.getValue());
            }
            else if ("abcfuture".equals(shortName))
            {
                this.setABCFuture(true);
            }
            else if ("p".equals(shortName))
            {
                this.setShowParseTrees(true);
            }
            else if ("i".equals(shortName))
            {
                this.setShowInstructions(true);
            }
            else if ("m".equals(shortName))
            {
                this.setShowMachineCode(true);
            }
            else if ("f".equals(shortName))
            {
                this.setShowFlowGraph(true);
            }
            else if ("exe".equals(shortName))
            {
                String exe = option.getValue();
                this.setAvmplusFilename(exe);
            }
            else if ("movieclip".equals(shortName))
            {
                this.setMakeMovieClip(true);
            }
            else if ("ES4".equals(shortName))
            {
                this.setDialect("ES4");
            }
            else if ("li".equals(shortName))
            {
                this.internalLibraries.add(option.getValue());
            }
            else if ("le".equals(shortName))
            {
                this.externalLibraries.add(option.getValue());
            }
            else if ("parallel".equals(shortName))
            {
                this.setParallel(true);
            }
            else if ("inline".equals(shortName))
            {
                this.setMergeABCs(true); // inlining requires merging of ABCs
                this.setEnableInlining(true);
            }
            else if ( "removedeadcode".equals(shortName) )
            {
                this.setRemoveDeadCode(true);
            }
            else
            {
                throw new UnrecognizedOptionException("Unrecognized option '" + shortName + "'", shortName);
            }
        }

        // Then any remaining arguments that were not options are interpreted as
        // source files to compile.
        final String[] remainingArgs = line.getArgs();
        if (remainingArgs != null)
        {
            for (int i = 0; i < remainingArgs.length; i++)
            {
                this.addSourceFilename(remainingArgs[i]);
            }
        }
        else
        {
            throw new MissingArgumentException("At least one source file must be specified after the list of options.");
        }

        return true;
    }
View Full Code Here

        String mid = "examine_allInOne";
        mh.frameworkTrace(cid, mid, enter);
        String pname = UiOption.AllInOne.pname();
        allInOneType = jobRequestProperties.getProperty(pname);
        if(allInOneType == null) {
            throw new MissingArgumentException(pname);
        }
        if(allInOneType.equalsIgnoreCase(local)) {
            String message = allInOneType;
            mh.frameworkDebug(cid, mid, message);
            used(pname);
View Full Code Here

TOP

Related Classes of org.apache.commons.cli.MissingArgumentException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.