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.

Parameter Switches

See original GitHub issue

Implement @Switch(“res”) to be used such as:

@Subcommand("set")
public void onResInfo(Player player, @Switch("r,res") Residence res, Permission perm, PermissionState value) {
  res.getPermissions().setState(perm, value);
}

With this, the following commands should work:

/res set 1111 build true
/res set build -res 1111 true
/res set -r 1111 build true
/res set build true -r 1111

When a parameter has a switch, it can be “Supplied” at any location of parameters (but not before the subcommands)

Switches should process command replacements

We can achieve this by first pre-parsing all switches during context resolution, marking what parameters have been satisfied, and then iterating the remainder of unsatisfied to complete them in order.

No new registration of switches needs to occur.

Switches should use - prefix by default, but the manager should allow customizing switch prefixes.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bundabrgcommented, Dec 10, 2020

I ended up implementing it in my own command parser (Docs) mainly for fun.

0reactions
heroslendercommented, Dec 9, 2020

Is this feature still being worked on? Saw the PR but there’s no activity there for over 2 years 😕

Also, would it be possible to use boolean @Switch without the the need to specify the value? For example: /foo -s would result in the Switch s being true, and /foo would result in s being false, wich could be obtained with the use of @Default("false").

The problem would really be the 1st one, maybe make it so that boolean switches don’t have a input value.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PowerShell: How to use Switch Parameter? - TechNet Articles
How to consume switch parameter? Demo function if switch -colortext is included you get color text output if not plain text with default ......
Read more >
Fun With the PowerShell Switch Parameter - Arcane Code
A switch is similar, you list the name of the switch on call to the function, but unlike a regular parameter you pass...
Read more >
Switching Parameter - an overview | ScienceDirect Topics
First, a switching parameter β in terms of which a transition point can be defined which separates the situations for which tumour progression...
Read more >
What Is a Switch Parameter? - PowerShell™ for SharePoint ...
A switch parameter is a parameter used with a cmdlet that does not take a value (or that is Boolean in nature and...
Read more >
Switch Parameter in Powershell - Stack Overflow
Makes sense, this is because in your function call (the last line of your script) you're never giving the function any 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