Skip to content

Commit

Permalink
fix 中文乱码
Browse files Browse the repository at this point in the history
  • Loading branch information
FuShaoLei committed Jan 29, 2024
1 parent c5b3c40 commit a078e2c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 25 deletions.
22 changes: 3 additions & 19 deletions src/main/java/ole/core/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Main {

public static void main(String[] args) {

new Main().run(args);
new Main().run(new String[]{"-g=C:\\Users\\spiderman\\Desktop\\ole-demo"});
}

private void run(String[] args) {
Expand All @@ -20,28 +20,12 @@ private void run(String[] args) {
if (oleOption.isHelpNeeded()) {
printUsage(oleOption);

System.err.println("==> user.dir = " + System.getProperty("user.dir"));

System.err.println("==> java.class.path = "+System.getProperty("java.class.path"));

String currentDir = Paths.get("").toAbsolutePath().toString();
System.out.println("currentDirectory: " + currentDir);

String newFileCurrentDir = new File("").getAbsolutePath().toString();
System.out.println("newFileCurrentDir: " + newFileCurrentDir);

try {String callerPath = Main.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
System.out.println("调用程序的路径是:" + callerPath);

} catch (Exception e){}


return;
}

if (oleOption.isGen()) {
System.err.println("help oleOption.getRootGenLocalPath()= " + oleOption.getRootGenLocalPath());
ole.generate(oleOption.getRootGenLocalPath());
System.err.println("help oleOption.getLocalPath()= " + oleOption.getLocalPath());
ole.generate(oleOption.getLocalPath());
return;
}

Expand Down
12 changes: 12 additions & 0 deletions src/main/java/ole/core/Ole.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ private static List<FileNode> OrganizeRootData(String path) {
}
}
}

rootNodeList.sort(new Comparator<FileNode>() {
@Override
public int compare(FileNode o1, FileNode o2) {
if (o1.isArticle() && o2.isFolder()) {
return -1;
} else if (o2.isArticle() && o1.isFolder()) {
return 1;
}
return 0;
}
});
return rootNodeList;
}

Expand Down
13 changes: 7 additions & 6 deletions src/main/java/ole/core/OleOption.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
package ole.core;

import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;

@Command(name = "ole", description = "a tool make md file to html", mixinStandardHelpOptions = true)
public class OleOption {

@Option(names = {"-g", "--gen"}, description = "generate")
private boolean gen;
@Option(names = {"-g", "--genPath"}, description = "generate")
private String localPath;

@Option(names = {"-h", "--help"}, description = "prints this message", usageHelp = true)
private boolean needHelp;


public boolean isGen() {
return gen;
return localPath != null;
}

public boolean isHelpNeeded() {
return needHelp || !gen;
return needHelp || localPath == null;
}

public String getRootGenLocalPath() {
return System.getProperty("user.dir");
public String getLocalPath() {
return localPath;
}
}
1 change: 1 addition & 0 deletions src/main/resources/template.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@200;300;400;700;900&family=Roboto+Mono&display=swap"
rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<body>
<main>
Expand Down

0 comments on commit a078e2c

Please sign in to comment.