All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javarepl.console.commands.Commands Maven / Gradle / Ivy

There is a newer version: 431
Show newest version
package javarepl.console.commands;


import com.googlecode.totallylazy.Sequence;
import com.googlecode.totallylazy.Sequences;
import com.googlecode.yadic.Container;
import javarepl.console.ConsoleConfig;

import static com.googlecode.totallylazy.Sequences.sequence;

public final class Commands {
    private final Container context;

    private Sequence> commands = Sequences.empty();

    public Commands(Container context, ConsoleConfig config) {
        this.context = context;
        this.commands = config.commands;
    }

    public Sequence allCommands() {
        return userCommands()
                .join(commandInstances(sequence(
                        NotAValidCommand.class,
                        ShowResult.class,
                        EvaluateExpression.class)));
    }

    Sequence userCommands() {
        return commandInstances(commands.cons(ShowHelp.class));
    }

    private Sequence commandInstances(Sequence> commands) {
        return commands.map(context::create);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy