当前位置: 首页>>代码示例>>Java>>正文


Java ArgumentParser类代码示例

本文整理汇总了Java中com.sk89q.intake.parametric.ArgumentParser的典型用法代码示例。如果您正苦于以下问题:Java ArgumentParser类的具体用法?Java ArgumentParser怎么用?Java ArgumentParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ArgumentParser类属于com.sk89q.intake.parametric包,在下文中一共展示了ArgumentParser类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateDescription

import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
@Override
public void updateDescription(Set<Annotation> annotations, ArgumentParser parser, ImmutableDescription.Builder builder) {
    for (Annotation annotation : annotations) {
        if (annotation instanceof Command) {
            Command command = (Command) annotation;

            // Handle the case for old commands where no usage is set and all of its
            // parameters are provider bindings, so its usage information would
            // be blank and would imply that there were no accepted parameters
            if (command.usage().isEmpty() && (command.min() > 0 || command.max() > 0)) {
                if (!parser.getUserParameters().isEmpty()) {
                    builder.setUsageOverride("(unknown usage information)");
                }
            }
        }
    }
}
 
开发者ID:EngineHub,项目名称:Intake,代码行数:18,代码来源:LegacyCommandsHandler.java

示例2: preInvoke

import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
@Override
public boolean preInvoke(List<? extends Annotation> annotations, ArgumentParser parser, Object[] args, CommandArgs commandArgs) throws CommandException, ArgumentException {
    for (Annotation annotation : annotations) {
        if (annotation instanceof Command) {
            Command command = (Command) annotation;

            if (commandArgs.size() < command.min()) {
                throw new MissingArgumentException();
            }

            if (command.max() != -1 && commandArgs.size() > command.max()) {
                List<String> unconsumedArguments = Lists.newArrayList();

                while (true) {
                    try {
                        String value = commandArgs.next();
                        if (commandArgs.position() >= command.max()) {
                            unconsumedArguments.add(value);
                        }
                    } catch (MissingArgumentException ignored) {
                        break;
                    }
                }

                throw new UnusedArgumentException(Joiner.on(" ").join(unconsumedArguments));
            }
        }
    }

    return true;
}
 
开发者ID:EngineHub,项目名称:Intake,代码行数:32,代码来源:LegacyCommandsHandler.java

示例3: fixCommandCompletion

import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
private void fixCommandCompletion(Collection<CommandMapping> commandMappings) {
    for (CommandMapping commandMapping : commandMappings) {
        final CommandCallable callable = commandMapping.getCallable();
        if (callable instanceof Dispatcher) {
            fixCommandCompletion(((Dispatcher) callable).getCommands());
        } else if (callable.getClass().getSimpleName().equals("MethodCallable")) {
            try {
                Field field = callable.getClass().getSuperclass().getDeclaredField("builder");
                field.setAccessible(true);
                final ParametricBuilder builder = (ParametricBuilder) field.get(callable);
                field = callable.getClass().getSuperclass().getDeclaredField("parser");
                field.setAccessible(true);
                final ArgumentParser parser = (ArgumentParser) field.get(callable);
                builder.setDefaultCompleter(this);
                field = parser.getClass().getDeclaredField("parameters");
                field.setAccessible(true);
                final List parameterList = (List) field.get(parser);
                if (parameterList.isEmpty()) continue;
                final Method bindingsMethod = parameterList.get(0).getClass()
                        .getMethod("getBinding");
                bindingsMethod.setAccessible(true);
                final List<Binding<?>> bindings = new ArrayList<>();
                for (Object o : parameterList) {
                    final Binding b = (Binding) bindingsMethod.invoke(o);
                    if (!b.getProvider().isProvided()) bindings.add(b);
                }
                bindingMap.put(commandMapping, bindings);
            } catch (Exception e) {
                CraftFX.log().severe("Error occurred while fixing tab completion for " +
                                "command %s",
                        MessageUtil.translate(null, callable.getDescription().getUsage()), e);
            }
        }
    }
}
 
开发者ID:t7seven7t,项目名称:CraftFX,代码行数:36,代码来源:Commands.java

示例4: preProcess

import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
@Override
public boolean preProcess(List<? extends Annotation> annotations, ArgumentParser parser, CommandArgs commandArgs) throws CommandException, ArgumentException {
    return true;
}
 
开发者ID:xxyy,项目名称:intake-spigot,代码行数:5,代码来源:InvokeAdapter.java

示例5: preInvoke

import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
@Override
public boolean preInvoke(List<? extends Annotation> annotations, ArgumentParser parser, Object[] args, CommandArgs commandArgs) throws CommandException, ArgumentException {
    return true;
}
 
开发者ID:xxyy,项目名称:intake-spigot,代码行数:5,代码来源:InvokeAdapter.java

示例6: postInvoke

import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
@Override
public void postInvoke(List<? extends Annotation> annotations, ArgumentParser parser, Object[] args, CommandArgs commandArgs) throws CommandException, ArgumentException {
    //no-op
}
 
开发者ID:xxyy,项目名称:intake-spigot,代码行数:5,代码来源:InvokeAdapter.java

示例7: updateDescription

import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
@Override
public void updateDescription(Set<Annotation> annotations, ArgumentParser parser, ImmutableDescription.Builder descriptionBuilder) {
    //no-op
}
 
开发者ID:xxyy,项目名称:intake-spigot,代码行数:5,代码来源:InvokeAdapter.java

示例8: updateDescription

import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
@Override
public void updateDescription(Set<Annotation> annotations, ArgumentParser parser, Builder descriptionBuilder) {
}
 
开发者ID:EngineHub,项目名称:Intake,代码行数:4,代码来源:AbstractInvokeListener.java

示例9: postInvoke

import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
@Override
public void postInvoke(List<? extends Annotation> annotations, ArgumentParser parser, Object[] args, CommandArgs commandArgs) throws CommandException, ArgumentException {
}
 
开发者ID:EngineHub,项目名称:Intake,代码行数:4,代码来源:LegacyCommandsHandler.java

示例10: updateDescription

import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
/**
 * Called to update the description of a command.
 *
 * @param annotations Annotations on the command
 * @param parser The parser containing parameter information
 * @param descriptionBuilder The description builder
 */
void updateDescription(Set<Annotation> annotations, ArgumentParser parser, ImmutableDescription.Builder descriptionBuilder);
 
开发者ID:EngineHub,项目名称:Intake,代码行数:9,代码来源:InvokeListener.java

示例11: preProcess

import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
/**
 * Called before arguments have been parsed.
 *
 * @param annotations The list of annotations on the command
 * @param parser The argument parser with parameter information
 * @param commandArgs The arguments provided by the user
 * @return Whether command execution should continue
 * @throws CommandException Thrown if there is a general command problem
 * @throws ArgumentException Thrown is there is an error with the arguments
 */
boolean preProcess(List<? extends Annotation> annotations, ArgumentParser parser, CommandArgs commandArgs) throws CommandException, ArgumentException;
 
开发者ID:EngineHub,项目名称:Intake,代码行数:12,代码来源:InvokeHandler.java

示例12: preInvoke

import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
/**
 * Called after arguments have been parsed but the command has yet
 * to be executed.
 *
 * @param annotations The list of annotations on the command
 * @param parser The argument parser with parameter information
 * @param args The result of the parsed arguments: Java objects to be passed to the command
 * @param commandArgs The arguments provided by the user
 * @return Whether command execution should continue
 * @throws CommandException Thrown if there is a general command problem
 * @throws ArgumentException Thrown is there is an error with the arguments
 */
boolean preInvoke(List<? extends Annotation> annotations, ArgumentParser parser, Object[] args, CommandArgs commandArgs) throws CommandException, ArgumentException;
 
开发者ID:EngineHub,项目名称:Intake,代码行数:14,代码来源:InvokeHandler.java

示例13: postInvoke

import com.sk89q.intake.parametric.ArgumentParser; //导入依赖的package包/类
/**
 * Called after the command has been executed.
 *
 * @param annotations The list of annotations on the command
 * @param parser The argument parser with parameter information
 * @param args The result of the parsed arguments: Java objects to be passed to the command
 * @param commandArgs The arguments provided by the user
 * @throws CommandException Thrown if there is a general command problem
 * @throws ArgumentException Thrown is there is an error with the arguments
 */
void postInvoke(List<? extends Annotation> annotations, ArgumentParser parser, Object[] args, CommandArgs commandArgs) throws CommandException, ArgumentException;
 
开发者ID:EngineHub,项目名称:Intake,代码行数:12,代码来源:InvokeHandler.java


注:本文中的com.sk89q.intake.parametric.ArgumentParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。