Package org.crsh.cli.descriptor

Examples of org.crsh.cli.descriptor.ArgumentDescriptor


      ParameterMatch parameterMatch = match.getParameter(parameter);
      Object value = parameterMatch != null ? parameterMatch.computeValue() : null;
      if (value == null) {
        if (parameter.getDeclaredType().isPrimitive() || parameter.isRequired()) {
          if (parameter instanceof ArgumentDescriptor) {
            ArgumentDescriptor argument = (ArgumentDescriptor)parameter;
            throw new SyntaxException("Missing argument " + argument.getName());
          } else {
            OptionDescriptor option = (OptionDescriptor)parameter;
            throw new SyntaxException("Missing option " + option.getNames());
          }
        }
View Full Code Here


        req.tokenizer.next();
      } else {
        final Token.Literal literal = (Token.Literal)token;
        List<? extends ArgumentDescriptor> arguments = req.command.getArguments();
        if (index < arguments.size()) {
          ArgumentDescriptor argument = arguments.get(index);
          switch (argument.getMultiplicity()) {
            case SINGLE:
              req.tokenizer.next();
              response.add(new Event.Argument(req.command, argument, Arrays.asList(literal)));
              response.status = next();
              break;
View Full Code Here

      @Argument()
      private int i;
    }
    CommandDescriptor<Instance<A>> c = CommandFactory.DEFAULT.create(A.class);
    assertEquals(1, c.getArguments().size());
    ArgumentDescriptor i = c.getArguments().get(0);
    assertEquals(ValueType.INTEGER, i.getType());
    assertEquals(Multiplicity.SINGLE, i.getMultiplicity());
    assertEquals(false, i.isRequired());
  }
View Full Code Here

      @Argument
      private List<Integer> j;
    }
    CommandDescriptor<Instance<A>> c = CommandFactory.DEFAULT.create(A.class);
    assertEquals(2, c.getArguments().size());
    ArgumentDescriptor i = c.getArguments().get(0);
    assertEquals(ValueType.INTEGER, i.getType());
    assertEquals(Multiplicity.SINGLE, i.getMultiplicity());
    assertEquals(false, i.isRequired());
    ArgumentDescriptor j = c.getArguments().get(1);
    assertEquals(ValueType.INTEGER, j.getType());
    assertEquals(Multiplicity.MULTI, j.getMultiplicity());
  }
View Full Code Here

  private Completion argument(CommandDescriptor<?> method, Completer completer, Delimiter delimiter) {
    List<? extends ArgumentDescriptor> arguments = method.getArguments();
    if (arguments.isEmpty()) {
      return new EmptyCompletion();
    } else {
      ArgumentDescriptor argument = arguments.get(0);
      return new ParameterCompletion("", delimiter, argument, completer);
    }
  }
View Full Code Here

          return argument(foo, completer, delimiter);
        }
      }
    } else if (last instanceof Event.Argument) {
      Event.Argument eventArgument = (Event.Argument)last;
      ArgumentDescriptor argument = eventArgument.getParameter();
      if (separator != null) {
        switch (argument.getMultiplicity()) {
          case SINGLE:
            List<? extends ArgumentDescriptor> arguments = eventArgument.getCommand().getArguments();
            int index = arguments.indexOf(argument) + 1;
            if (index < arguments.size()) {
              ArgumentDescriptor nextArg = arguments.get(index);
              return new ParameterCompletion("", delimiter, nextArg, completer);
            } else {
              return new EmptyCompletion();
            }
          case MULTI:
View Full Code Here

TOP

Related Classes of org.crsh.cli.descriptor.ArgumentDescriptor

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.