Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [osgi-users] Specifying required parameter in Gogo command

Stefan,

Thanks for reaching out. I believe that in order to keep it simple I may have missed showing the real issue.
Here is the command:

@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
}

For arguments that are truly required you can see the use of the REQ constant to show that.

I can understand your approach if maybe dealing with a single argument, but here we cleary need the ability to specify absentValue=null or equivalent for some of the parameters, which is where we're struggling to match the specification.

Thanks
Alain





On Thu, Mar 4, 2021 at 2:16 PM Stefan Bischof <stbischof@xxxxxxxxxxx> wrote:

I think this could be done by overloading the method.

@Descriptor("...")
String foo(){
return foo(null);
}

@Descriptor("...")
String foo(@Parameter(names="-ps")String text){

}



On 2/17/21 7:11 PM, Alain Picard wrote:
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 checks for null, otherwise it will add the "[optional]" tag.

Thanks
Alain


_______________________________________________
osgi-users mailing list
osgi-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/osgi-users
_______________________________________________
osgi-users mailing list
osgi-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/osgi-users

Back to the top