InitCLI.java
package org.docascode.init;
import org.docascode.utils.DocAsCodeException;
import org.docascode.utils.ExitCode;
import org.docascode.utils.Utils;
import org.slf4j.helpers.Util;
import picocli.CommandLine;
import java.io.File;
import java.io.IOException;
@CommandLine.Command(name = "init")
public class InitCLI implements Runnable {
@CommandLine.Parameters(arity = "0..1", description = "The name of directory to initialize")
private File directory;
@Override
public void run() {
if (directory == null) {
directory = new File(".");
}
Utils.setDirectory(directory);
InitCtrl initCtrl = new InitCtrl();
try {
initCtrl.initGitRepository(directory);
initCtrl.copyDocAsCodeFiles(directory);
initCtrl.initGitConfig(directory);
} catch (DocAsCodeException e) {
Utils.error(e.getMessage(), ExitCode.RUNTIME_ERROR);
}
Utils.success("Successfully initialized DocAsCode Repository in " + directory.getAbsolutePath());
}
}