[Bug] First argument is not being used in default command
See original GitHub issueWhat’s happening: Registering a command which is the default, the first argument “username” is not being used. We end up with the args list having all the arguments, and username doesn’t get passed down at all. Here is an example piece of code and my IDE’s debugger values.
Example:
@CommandAlias("msg")
public class MessageCommand extends BaseCommand {
@Default
public void execute(CommandIssuer sender, String username, String[] args) {
AsyncDatabase.submit(() -> {
UUID playerUUID = PlayerManager.getUUIDForUsername(args[0]);
if(!RedisManager.getPlayers().contains(playerUUID)){
sender.sendMessage("That player is not online.");
return;
}
StringBuilder stringBuilder = new StringBuilder();
for(int i = 1; 1 < args.length; i++){
stringBuilder.append(args[i]).append(" ");
}
});
}
}
Hopefully you understand what is happening here.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Console: Running default command causes invalid ... - GitHub
Running into this issue but not with an argument as first command line ... defaults first then use the default command and raise...
Read more >Use second argument for optional first argument if not ...
For clarification of my specific use case: I'm trying to define a command that passes a variable on as an option to an...
Read more >Process all arguments except the first one (in a bash script)
@Zenexer: As I understand it, the question was how to pass all but the first argument to "to other part of script", with...
Read more >Change Command Default (CHGCMDDFT) - IBM
Default values for parameters are shown on the first command prompt screen. ... The new parameter default must be valid for the parameter...
Read more >argparse — Parser for command-line options, arguments and ...
For a more gentle introduction to Python command-line parsing, have a look at the argparse tutorial. ... Default value used when an argument...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this should now be fixed, CommandIssuer was accidently made a required arg, which you were using.
Reopen if it still occurs after pulling latest ACF.
Yeah sure! No worries