Parameter Switches
See original GitHub issueImplement @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:
- Created 5 years ago
- Reactions:2
- Comments:12 (5 by maintainers)
Top 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 >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 ended up implementing it in my own command parser (Docs) mainly for fun.
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 Switchs
beingtrue
, and/foo
would result ins
beingfalse
, 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.