Skip to content

Unify Argument Validation and Tab Completion #19

@hhenrichsen

Description

@hhenrichsen

I propose that we turn argument handling into an interface that can both provide arguments and parse them. This will also have to be reflected in the API for commands, so something like this:

void addArgumentHandler(int position, ArgumentHandler argumentHandler);

And then provide an interface like this:

public interface ArgumentHandler<T> {
    public T validate(String argument);
    public List<String> provideCompletions(String partial);
}

Perhaps a utility method on this interface might be good to unify separate validators and tab completers.

Another thing that we might consider is how these are passed down to commands. We register the handlers in the commands, should they be added to some kind of map that we can be sure will be of valid types? I'm not entirely sure how I want to implement this as of right now, but that might be a good option. I want to try and avoid casts if at all possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions