You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Alain Picard <ap...@benchmarkconsulting.com> on 2021/03/04 21:12:28 UTC

Specifying required parameter in Gogo command

Hi,

I asked the following question on the osgi mailing list and was correctly
reminded that this might be a better location since it's related to gogo.

I am trying to specify some required parameters in Gogo but I can't find a
way to set absentValue to null (can't just not provide it as it is
required).

This won't compile:
@Parameter(names="-ps") @Descriptor(PS_DESCR) String psName,

Example:
@Parameter(names="-ps", absentValue= "") @Descriptor(PS_DESCR) String
psName,

results in:
-ps   ProjectSpace name [optional]

Where I want it not to show up as optional.

The code
<https://github.com/apache/felix-dev/blob/31aea2b06d5bd0e620f86b5874904a1616683873/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Shell.java#L708>
checks for null, otherwise it will add the "[optional]" tag.

Full example:
@Descriptor("...")
public void createTenantAndUserOnKCBA(
@Parameter(names={"-t", "--tenant"}, absentValue="")
@Descriptor(TENANT_DESCR + REQ) String tenantName,
@Parameter(names="-ps", absentValue= "") @Descriptor(PS_DESCR) String
psName,
@Parameter(names="-email", absentValue="") @Descriptor(EMAIL_DESCR + REQ)
String email,
@Parameter(names="-fname", absentValue="") @Descriptor(FNAME_DESCR + REQ)
String firstName,
@Parameter(names="-lname", absentValue="") @Descriptor(LNAME_DESCR + REQ)
String lastName,
@Parameter(names="-full", absentValue="") @Descriptor(FULL_NAME_DESCR)
String fullName,
@Parameter(names="-pwd", absentValue="") @Descriptor(PASS_DESCR + REQ)
String password,
@Parameter(names="-ent", absentValue="") @Descriptor(ENT_DESCR) String
enterpriseName) {
//perform command
}

Thanks
Alain