PoweredByApartium / cocoa-beans

General purpose library for Java & Spigot
MIT License
4 stars 0 forks source link

Optional for command parameter #69

Closed ikfir closed 1 month ago

ikfir commented 1 month ago

An example

@SubCommand("<?string>")
public void example(Optional<String> optStr) {
  // Do something
}

it also can just give you a null

@SubCommand("<?string>")
public void example(String str) { // String could be null
  // Do something
}

We have a few edge cases

  1. no parameter: should put null or skip
  2. parameter not match parser: should put null or skip

Should we make it dynamic by given multiple way to request optional or just include both cases?