package ee.shy.cli.command;

import ee.shy.cli.Command;
import ee.shy.cli.HelptextBuilder;
import ee.shy.core.Repository;

import java.io.IOException;

/**
 * A command to checkout.
 */
public class CheckoutCommand implements Command {
    @Override
    public void execute(String[] args) throws IOException {
        Repository repository = Repository.newExisting();
        repository.checkout(args[0]);
    }

    @Override
    public String getHelp() {
        return new HelptextBuilder()
                .addWithArgs("<String>", "Checkouts to given commit or branch")
                .addDescription("This command checkouts to commit with hash of <string>.")
                .create();
    }

    @Override
    public String getHelpBrief() {
        return "Checkouts to given commit.";
    }
}
@@ -791,10 +791,232 @@
 %22;%0A    %7D
+%0A%0A    @Override%0A    public String%5B%5D getCompletion(String%5B%5D args) throws IOException %7B%0A        Repository repository = Repository.newExisting();%0A        return repository.getBranches().keySet().toArray(new String%5B0%5D);%0A    %7D
 %0A%7D

Add branch completions to checkout command