This commit is contained in:
parent
288f6d118b
commit
93244edd0e
2 changed files with 27 additions and 7 deletions
|
@ -5,6 +5,7 @@ import eu.m724.blog.data.Post;
|
||||||
import eu.m724.blog.data.Site;
|
import eu.m724.blog.data.Site;
|
||||||
import in.wilsonl.minifyhtml.Configuration;
|
import in.wilsonl.minifyhtml.Configuration;
|
||||||
import in.wilsonl.minifyhtml.MinifyHtml;
|
import in.wilsonl.minifyhtml.MinifyHtml;
|
||||||
|
import org.apache.commons.cli.*;
|
||||||
import org.apache.commons.io.file.PathUtils;
|
import org.apache.commons.io.file.PathUtils;
|
||||||
import org.eclipse.jgit.api.Git;
|
import org.eclipse.jgit.api.Git;
|
||||||
import org.eclipse.jgit.lib.RepositoryBuilder;
|
import org.eclipse.jgit.lib.RepositoryBuilder;
|
||||||
|
@ -27,18 +28,37 @@ public class Main {
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
System.out.println("Hello world!");
|
System.out.println("Hello world!");
|
||||||
|
|
||||||
var start = System.nanoTime();
|
var options = new Options()
|
||||||
|
.addOption("f", "force", false, "Overwrite current build. Default: no")
|
||||||
|
.addOption("dir", "working-dir", true, "Working directory. Default: current directory")
|
||||||
|
.addOption("t", "template-dir", true, "Template directory. Default: working directory/template")
|
||||||
|
.addOption("o", "output-dir", true, "Output directory. Default: working directory/generated_out")
|
||||||
|
.addOption("s", "server", false, "Run webserver. Default: no");
|
||||||
|
|
||||||
var workingDirectory = Path.of("m724");
|
CommandLine commandLine;
|
||||||
var templateDirectory = workingDirectory.resolve("template");
|
try {
|
||||||
var outputDirectory = workingDirectory.resolve("generated_out");
|
commandLine = new DefaultParser().parse(options, args);
|
||||||
var force = true;
|
} catch (ParseException e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
new HelpFormatter().printHelp("utility-name", options);
|
||||||
|
|
||||||
var server = true;
|
System.exit(1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var workingDirectory = Path.of(commandLine.getOptionValue("working-dir", "."));
|
||||||
|
var templateDirectory = Path.of(commandLine.getOptionValue("output-dir", workingDirectory.resolve("template").toString()));
|
||||||
|
var outputDirectory = Path.of(commandLine.getOptionValue("output-dir", workingDirectory.resolve("generated_out").toString()));
|
||||||
|
var force = commandLine.hasOption("force");
|
||||||
|
|
||||||
|
var server = commandLine.hasOption("server");
|
||||||
var openBrowser = true;
|
var openBrowser = true;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
var start = System.nanoTime();
|
||||||
|
|
||||||
var repository = new RepositoryBuilder()
|
var repository = new RepositoryBuilder()
|
||||||
.setGitDir(workingDirectory.resolve(".git").toFile())
|
.setGitDir(workingDirectory.resolve(".git").toFile())
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -15,7 +15,7 @@ public record Site(
|
||||||
Map<String, Object> custom
|
Map<String, Object> custom
|
||||||
) {
|
) {
|
||||||
public static Site fromConfig(Git git) throws IOException {
|
public static Site fromConfig(Git git) throws IOException {
|
||||||
var content = Files.readString(git.getRepository().getDirectory().toPath().getParent().resolve("config.json"));
|
var content = Files.readString(git.getRepository().getDirectory().toPath().getParent().resolve("site-config.json"));
|
||||||
var json = new JSONObject(content);
|
var json = new JSONObject(content);
|
||||||
|
|
||||||
String name = null;
|
String name = null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue