Package org.jboss.aesh.cl.internal

Examples of org.jboss.aesh.cl.internal.ParameterInt


   @SuppressWarnings({ })
   @Override
   public void complete(CompleteOperation completeOperation)
   {
       try {
           ParameterInt param = context.getParser().getParameters().get(0);
           // complete command names
           if (param.getName().startsWith(completeOperation.getBuffer()))
               completeOperation.addCompletionCandidate(param.getName());
               // display all the options/arguments
           else if (param.getName().equals(completeOperation.getBuffer().trim()))
           {
               defaultCompletion(completeOperation);
           }
           // complete options/arguments
           else if (completeOperation.getBuffer().startsWith(param.getName()))
           {
               ParsedCompleteObject completeObject = null;
               completeObject = new CommandLineCompletionParser(context.getParser())
                       .findCompleteObject(completeOperation.getBuffer());
               //logger.info("ParsedCompleteObject: " + completeObject);
               if (completeObject.doDisplayOptions())
               {
                   // we have a partial/full name
                   if (completeObject.getName() != null && completeObject.getName().length() > 0)
                   {
                       if (param.findPossibleLongNamesWitdDash(completeObject.getName()).size() > 0)
                       {
                           // only one param
                           if (param.findPossibleLongNamesWitdDash(completeObject.getName()).size() == 1)
                           {
                               completeOperation.addCompletionCandidate(param.findPossibleLongNamesWitdDash(
                                       completeObject.getName()).get(0));
                               completeOperation.setOffset(completeOperation.getCursor() -
                                       completeObject.getOffset());
                           }
                           // multiple params
                           else
                               completeOperation.addCompletionCandidates(param.findPossibleLongNamesWitdDash(completeObject
                                       .getName()));
                       }
                   }
                   // display all our params
                   else
                   {
                       if (param.getOptionLongNamesWithDash().size() > 1)
                       {
                           completeOperation.addCompletionCandidates(param.getOptionLongNamesWithDash());
                       }
                       else
                       {
                           completeOperation.addCompletionCandidates(param.getOptionLongNamesWithDash());
                           completeOperation.setOffset(completeOperation.getCursor() -
                                   completeObject.getOffset());
                       }
                   }
               }
View Full Code Here


   public static CommandLineParser generateParser(UICommand command, ShellContext context)
   {
      ParserBuilder builder = new ParserBuilder();

      ParameterInt parameter =
               new ParameterInt(command.getMetadata().getName(), command.getMetadata().getDescription());
      for (InputComponent<?, ?> input : context.getInputs())
      {
         if (!input.getName().equals("arguments"))
         {
            try
            {
               if (input.getValueType() == Boolean.class)
               {
                  parameter.addOption(
                           new OptionBuilder()
                                    .longName(input.getName())
                                    .hasValue(false)
                                    .description(input.getLabel())
                                    .create());
               }
               else
               {
                  parameter.addOption(
                           new OptionBuilder().longName(input.getName())
                                    .description(input.getLabel())
                                    .required(input.isRequired())
                                    .create());
               }
View Full Code Here

        params.add(parameterInt);
    }

    public CommandLineParser(String name, String usage) {
        params = new ArrayList<ParameterInt>();
        params.add(new ParameterInt(name, usage));
    }
View Full Code Here

    }

    public ParameterInt generateParameter() throws IllegalArgumentException {
        if(name == null || name.length() < 1)
            throw new RuntimeException("The parameter name must be defined");
        return  new ParameterInt(name, usage, argumentType, options);
    }
View Full Code Here

   @SuppressWarnings({ "rawtypes", "unchecked" })
   @Override
   public void complete(CompleteOperation completeOperation)
   {
      ParameterInt param = context.getParser().getParameters().get(0);
      // complete command names
      if (param.getName().startsWith(completeOperation.getBuffer()))
         completeOperation.addCompletionCandidate(param.getName());
      // display all the options/arguments
      else if (param.getName().equals(completeOperation.getBuffer().trim()))
      {
         completeOperation.addCompletionCandidates(param.getOptionLongNamesWithDash());
      }
      // complete options/arguments
      else if (completeOperation.getBuffer().startsWith(param.getName()))
      {
         ParsedCompleteObject completeObject = null;
         try
         {
            completeObject = new CommandLineCompletionParser(context.getParser())
                     .findCompleteObject(completeOperation.getBuffer());
         }
         catch (CommandLineParserException e)
         {
            logger.info(e.getMessage());
            return;
         }
         logger.info("ParsedCompleteObject: " + completeObject);
         if (completeObject.doDisplayOptions())
         {
            // we have a partial/full name
            if (completeObject.getName() != null && completeObject.getName().length() > 0)
            {
               if (param.findPossibleLongNamesWitdDash(completeObject.getName()).size() > 0)
               {
                  // only one param
                  if (param.findPossibleLongNamesWitdDash(completeObject.getName()).size() == 1)
                  {
                     completeOperation.addCompletionCandidate(param.findPossibleLongNamesWitdDash(
                              completeObject.getName()).get(0));
                     completeOperation.setOffset(completeOperation.getCursor() -
                              completeObject.getOffset());
                  }
                  // multiple params
                  else
                     completeOperation.addCompletionCandidates(param.findPossibleLongNamesWitdDash(completeObject
                              .getName()));
               }
            }
            // display all our params
            else
            {
               if (param.getOptionLongNamesWithDash().size() > 1)
               {
                  completeOperation.addCompletionCandidates(param.getOptionLongNamesWithDash());
               }
               else
               {
                  completeOperation.addCompletionCandidates(param.getOptionLongNamesWithDash());
                  completeOperation.setOffset(completeOperation.getCursor() -
                           completeObject.getOffset());
               }
            }
         }
View Full Code Here

   public static CommandLineParser generateParser(UICommand command, ShellContext context)
   {
      ParserBuilder builder = new ParserBuilder();

      ParameterInt parameter =
               new ParameterInt(command.getMetadata().getName(), command.getMetadata().getDescription());
      for (InputComponent<?, ?> input : context.getInputs())
      {
         if (!input.getName().equals("arguments"))
         {
            try
            {
               if (input.getValueType() == Boolean.class)
               {
                  parameter.addOption(
                           new OptionBuilder()
                                    .longName(input.getName())
                                    .hasValue(false)
                                    .description(input.getLabel())
                                    .create());
               }
               else
               {
                  parameter.addOption(
                           new OptionBuilder().longName(input.getName())
                                    .description(input.getLabel())
                                    .required(input.isRequired())
                                    .create());
               }
View Full Code Here

TOP

Related Classes of org.jboss.aesh.cl.internal.ParameterInt

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.