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

sirius.kernel.health.console.HelpCommand Maven / Gradle / Ivy

Go to download

Provides common core classes and the microkernel powering all Sirius applications

There is a newer version: 12.9.1
Show newest version
/*
 * Made with all the love in the world
 * by scireum in Remshalden, Germany
 *
 * Copyright by scireum GmbH
 * http://www.scireum.de - [email protected]
 */

package sirius.kernel.health.console;

import sirius.kernel.di.GlobalContext;
import sirius.kernel.di.std.Part;
import sirius.kernel.di.std.Register;
import sirius.kernel.info.Product;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * Console command which generates a help screen listing all commands.
 */
@Register
public class HelpCommand implements Command {

    @Part
    private GlobalContext ctx;

    @Override
    public void execute(Output output, String... params) throws Exception {
        output.blankLine();
        output.apply("C O N S O L E  -  %s", Product.getProduct());
        output.blankLine();
        output.apply("%-20s %s", "CMD", "DESCRIPTION");
        output.separator();
        List parts = new ArrayList<>(ctx.getParts(Command.class));
        parts.sort(Comparator.comparing(Command::getName));
        for (Command cmd : parts) {
            output.apply("%-20s %s", cmd.getName(), cmd.getDescription());
        }
        output.separator();
    }

    @Override
    @Nonnull
    public String getName() {
        return "help";
    }

    @Override
    public String getDescription() {
        return "Generates this help screen.";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy