Package org.crsh.cli.descriptor

Examples of org.crsh.cli.descriptor.OptionDescriptor


        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());
          }
        }
      } else {
        ((Binding)parameter).set(target, args, value);
      }
View Full Code Here


              } else {
                response.add(new Event.Stop.Unresolved.NoSuchOption(optionToken));
              }
            }
          } else {
            OptionDescriptor desc = req.command.resolveOption(literal.getValue());
            if (desc != null) {
              req.tokenizer.next();
              int arity = desc.getArity();
              LinkedList<Token.Literal.Word> values = new LinkedList<Token.Literal.Word>();
              while (arity > 0) {
                if (req.tokenizer.hasNext()) {
                  Token a = req.tokenizer.peek();
                  if (a instanceof Token.Whitespace) {
View Full Code Here

  @Override
  protected void addParameter(ParameterDescriptor parameter) throws IntrospectionException {

    // Check we can add the option
    if (parameter instanceof OptionDescriptor) {
      OptionDescriptor option = (OptionDescriptor)parameter;
      Set<String> blah = new HashSet<String>();
      for (String optionName : option.getNames()) {
        blah.add((optionName.length() == 1 ? "-" : "--") + optionName);
      }
      for (MethodDescriptor<T> method : methods.values()) {
        Set<String> diff = new HashSet<String>(method.getOptionNames());
        diff.retainAll(blah);
View Full Code Here

      @Option(names = "i")
      private int i;
    }
    CommandDescriptor<Instance<A>> ai = CommandFactory.DEFAULT.create(A.class);
    assertEquals(1,ai.getOptions().size());
    OptionDescriptor i = ai.getOption("-i");
    assertEquals(Arrays.asList("i"),i.getNames());
  }
View Full Code Here

      @Option(names = "I")
      private int i;
    }
    CommandDescriptor<Instance<A>> ai = CommandFactory.DEFAULT.create(A.class);
    assertEquals(1,ai.getOptions().size());
    OptionDescriptor i = ai.getOption("-I");
    assertEquals(Arrays.asList("I"),i.getNames());
  }
View Full Code Here

      String l;
    }

    CommandDescriptor<Instance<A>> a = CommandFactory.DEFAULT.create(A.class);
    assertEquals(1,a.getOptions().size());
    OptionDescriptor i = a.getOption("-l");
    assertEquals(Arrays.asList("l"),i.getNames());
    assertTrue(i.getAnnotation() instanceof Level);
  }
View Full Code Here

        @Option(names = "a") String s) {}
    }

    CommandDescriptor<Instance<A>> c = CommandFactory.DEFAULT.create(A.class);
    CommandDescriptor<Instance<A>> m = c.getSubordinate("m");
    OptionDescriptor a = m.getOption("-a");
    assertEquals("option_usage", a.getUsage());
    assertEquals("option_usage", a.getDescription().getUsage());
    assertEquals("option_man", a.getDescription().getMan());
  }
View Full Code Here

      void m(@Foo String s) {}
    }

    CommandDescriptor<Instance<A>> c = CommandFactory.DEFAULT.create(A.class);
    CommandDescriptor<Instance<A>> m = c.getSubordinate("m");
    OptionDescriptor a = m.getOption("-a");
    assertEquals("foo_usage", a.getUsage());
    assertEquals("foo_usage", a.getDescription().getUsage());
    assertEquals("foo_man", a.getDescription().getMan());
  }
View Full Code Here

      @Command void m(@Bar String s) {}
    }

    CommandDescriptor<Instance<A>> c = CommandFactory.DEFAULT.create(A.class);
    CommandDescriptor<Instance<A>> m = c.getSubordinate("m");
    OptionDescriptor a = m.getOption("-a");
    assertEquals("", a.getUsage());
    assertEquals(new Description(), a.getDescription());
  }
View Full Code Here

        @Foo String s) {}
    }

    CommandDescriptor<Instance<A>> c = CommandFactory.DEFAULT.create(A.class);
    CommandDescriptor<Instance<A>> m = c.getSubordinate("m");
    OptionDescriptor a = m.getOption("-a");
    assertEquals("option_usage", a.getUsage());
    assertEquals("option_usage", a.getDescription().getUsage());
    assertEquals("foo_man", a.getDescription().getMan());
  }
View Full Code Here

TOP

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

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.