private <C extends BaseCommand> CommandResolution createCommand(final Class<C> commandClass) throws CommandException { final ClassShellCommand<C> shellCommand; final String description; try { shellCommand = new ClassShellCommand<C>(commandClass); description = shellCommand.describe(commandClass.getSimpleName(), Format.DESCRIBE); } catch (IntrospectionException e) { throw new CommandException(ErrorKind.SYNTAX, "Invalid cli annotation in command " + commandClass.getSimpleName(), e); } return new CommandResolution() { @Override public String getDescription() { return description; } @Override public Command<?> getCommand() throws CommandException { return shellCommand; } }; } }
protected Completer getCompleter(final RuntimeContext context) throws CommandException { final T command = createCommand(); if (command instanceof Completer) { command.context = context; return (Completer)command; } else { return null; } }
public ProducerCommandMatch(ClassShellCommand<T> shellCommand, CommandInvoker<Instance<T>, ?> invoker, Class<P> producedType) { super(shellCommand); // this.invoker = invoker; this.producedType = producedType; this.name = shellCommand.getDescriptor().getName(); }
return getPipeInvoker(tmp); } else { return getProducerInvoker(invoker, producedType);
private <C extends BaseCommand> ClassShellCommand<C> make(Class<C> clazz) throws IntrospectionException { return new ClassShellCommand<C>(clazz); }
return getPipeInvoker(tmp); } else { return getProducerInvoker(invoker, producedType);
@Override public Command<?> resolveCommand(String name) throws CommandException, NullPointerException { if ("mycommand".equals(name)) { try { return new ClassShellCommand<mycommand>(mycommand.class); } catch (IntrospectionException e) { throw new CommandException(ErrorKind.EVALUATION, "Invalid cli annotations", e); } } return null; } }
final ClassShellCommand command; try { command = new ClassShellCommand(clazz); final String description = command.describe(name, Format.DESCRIBE); return new CommandResolution() { @Override
return getPipeInvoker(tmp); } else { return getProducerInvoker(invoker, producedType);
public <B extends BaseCommand> String execute(Class<B> commandClass, String... args) throws IntrospectionException, IOException, CommandException { return execute(new ClassShellCommand<B>(commandClass), args); }
public PipeCommandMatch(ClassShellCommand<T> baseShellCommand, CommandInvoker<Instance<T>, PC> invoker) { super(baseShellCommand); this.invoker = invoker; ret = invoker.getGenericReturnType(); consumedType = (Class<C>)Utils.resolveToClass(ret, Pipe.class, 0); producedType = (Class<P>)Utils.resolveToClass(ret, Pipe.class, 1); name = baseShellCommand.getDescriptor().getName(); }
public CommandInvoker<C, P> getInvoker() throws CommandException { final T command = baseShellCommand.createCommand(); return getInvoker(command); }
private <C extends BaseCommand> CommandResolution createCommand(final Class<C> commandClass) throws CommandException { final ClassShellCommand<C> shellCommand; final String description; try { shellCommand = new ClassShellCommand<C>(commandClass); description = shellCommand.describe(commandClass.getSimpleName(), Format.DESCRIBE); } catch (IntrospectionException e) { throw new CommandException(ErrorKind.SYNTAX, "Invalid cli annotation in command " + commandClass.getSimpleName(), e); } return new CommandResolution() { @Override public String getDescription() { return description; } @Override public Command<?> getCommand() throws CommandException { return shellCommand; } }; } }
private <C extends BaseCommand> ClassShellCommand<C> make(Class<C> clazz) throws IntrospectionException { return new ClassShellCommand<C>(clazz); }
public ProducerCommandMatch(ClassShellCommand<T> shellCommand, CommandInvoker<Instance<T>, ?> invoker, Class<P> producedType) { super(shellCommand); // this.invoker = invoker; this.producedType = producedType; this.name = shellCommand.getDescriptor().getName(); }
protected Completer getCompleter(final RuntimeContext context) throws CommandException { final T command = createCommand(); if (command instanceof Completer) { command.context = context; return (Completer)command; } else { return null; } }
private <C extends BaseCommand> CommandResolution createCommand(final Class<C> commandClass) throws CommandException { final ClassShellCommand<C> shellCommand; final String description; try { shellCommand = new ClassShellCommand<C>(commandClass); description = shellCommand.describe(commandClass.getSimpleName(), Format.DESCRIBE); } catch (IntrospectionException e) { throw new CommandException(ErrorKind.SYNTAX, "Invalid cli annotation in command " + commandClass.getSimpleName(), e); } return new CommandResolution() { @Override public String getDescription() { return description; } @Override public Command<?> getCommand() throws CommandException { return shellCommand; } }; } }
private <C extends BaseCommand> ClassShellCommand<C> make(Class<C> clazz) throws IntrospectionException { return new ClassShellCommand<C>(clazz); }
public ProducerCommandMatch(ClassShellCommand<T> shellCommand, CommandInvoker<Instance<T>, ?> invoker, Class<P> producedType) { super(shellCommand); // this.invoker = invoker; this.producedType = producedType; this.name = shellCommand.getDescriptor().getName(); }
protected Completer getCompleter(final RuntimeContext context) throws CommandException { final T command = createCommand(); if (command instanceof Completer) { command.context = context; return (Completer)command; } else { return null; } }