Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

We discussed several approaches to declare arguments for commands. There are three use cases that must be supported.

  • Interactive shell
  • Bndtools UI
  • Scripts

Metatype interfaces

In this approach the arguments are grouped in interfaces.

@Meta.OCD interface NameAndType {
	enum TYPE { CLASS, INTERFACE };
	@Meta.AD(name="FQN", description="The fully qualified name of the class.") FQN name();
	@Meta.AD(description="The type (class or interface)") TYPE type();
}

@Command()
public void main() {	
	NameAndType nat = m_prompt.ask(NameAndType.class, values);
 
	System.out.println("N: " + nat.name());
	System.out.println("T: " + nat.type());

Scripting can be implemented by recording arguments before executing the command.

 

Upsides:

  • Questions are grouped, this is ideal for generating wizards in Bndtools


Downsides:

  • The questions are "disconnected" from the command implementations. This is less obvious to program.
  • Difficult to support command completion

Annotated arguments

@Command()
public void main(@Argument(name="name") String name, @Argument(name="type") FQN type) {	

	

Scripting can be implemented by recording arguments before executing the command.

Upsides:

  • Obvious to implement
  • Easy to support both passing arguments immediately, and asking the user for answers during execution of the command
  • Easy to implement argument completion


Downsides:

  • No way to group questions, besides just showing all of them in the same wizard. Note that this is only a problem when multiple wizard pages are required in Bndtools.

 

 

 

 

  • No labels