Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support positional arguments #91

@rvesse

Description

@rvesse

Currently @Arguments is a general annotation that can only be applied to a single field and collects all non-option values into that field. There are various use cases where it might be nicer to support true positional arguments i.e. a new @PositionalArgument annotation such that arguments could be captured on separate fields and provide more detailed help specific to each argument

e.g.

@Command(name = "pos-args")
public class PositionalArgumentExample {

  @PositionalArgument(title = "Source", description = "The source file", position = { 0 })
  private String source;

  @PositionalArgument(title = "Target", description = "The target file", position = { 1 })
  private String target;

  @Arguments(title = "ExtraArg", description = "Extra arguments")
  private List<String> extraArgs = new ArrayList();
}

Which would be used as follows:

> pos-args source.txt target.txt foo bar

Where source.txt would be set to the source field, target.txt set to the target field and the additional arguments passed to the extraArgs field

Metadata

Metadata

Assignees

Labels

enhancementProposed Enhancement/Featureuser-experienceImproves user experience

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions