question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] First argument is not being used in default command

See original GitHub issue

What’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.

Image of debugger 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:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
aikarcommented, Sep 10, 2018

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.

0reactions
Rushmeadcommented, Sep 10, 2018

Yeah sure! No worries

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found