Closed nikosgram closed 9 years ago
I'm using the method getSimpleUsageString to get the Usage from the command and the output message is the bellow:
getSimpleUsageString
Usage code:
try { return dispatcher.call(command.getName() + ' ' + Joiner.on(' ').join(args), namespace, ImmutableList.of()); } catch (InvalidUsageException e) { sender.sendMessage(ChatColor.GRAY + "Usage: " + ChatColor.RED + e.getSimpleUsageString("/")); return true; } catch (InvocationCommandException e) { sender.sendMessage(ChatColor.RED + e.getLocalizedMessage()); e.printStackTrace(); } catch (CommandException e) { sender.sendMessage(ChatColor.RED + e.getLocalizedMessage()); return true; } catch (AuthorizationException e) { sender.sendMessage(command.getPermissionMessage()); return true; }
Installing code:
Injector injector = Intake.createInjector(); injector.install(new PrimitivesModule()); injector.install(new BukkitModule()); injector.install(new StoreModule()); ParametricBuilder builder = new ParametricBuilder(injector); builder.setAuthorizer(new BukkitAuthorizer()); dispatcher = new CommandGraph() .builder(builder) .commands() .group("store") .registerMethods(this) .parent() .graph() .getDispatcher();
Registered Method:
@Command(aliases = "version", desc = "Show the version!") public void version(CommandSender sender) { sender.sendMessage("&e" + getDescription().getName() + " " + getDescription().getVersion()); }
Intake Version: 4.0-SNAPSHOT
4.0-SNAPSHOT
You need to define usage in the Command annotation (at least until this is fixed), e.g.:
@Command(aliases = "version", desc = "Show the version", usage = "/store version")
I'm using the method
getSimpleUsageString
to get the Usage from the command and the output message is the bellow:Usage code:
Installing code:
Registered Method:
Intake Version:
4.0-SNAPSHOT