asset忘了上传了,重新传一下,增加了模板引擎(见README),修复了printable的目录bug
This commit is contained in:
commit
294abad18b
550 files changed
+62291
No files matched your search
@@ -0,0 +1,69 @@
|
||||
// deno-lint-ignore no-import-prefix
|
||||
import { parse } from "https://deno.land/[email protected]/flags/mod.ts";
|
||||
import { parse as parseToml } from "@std/toml";
|
||||
import { match_sub_command_to_function } from "./cli/match.ts";
|
||||
|
||||
export const args = parse(Deno.args, {
|
||||
string: [
|
||||
"config",
|
||||
"vars-file",
|
||||
"from",
|
||||
"url",
|
||||
"user",
|
||||
"password",
|
||||
"remote-dir",
|
||||
"type",
|
||||
],
|
||||
boolean: ["local-cache", "just-local-cache"],
|
||||
alias: { v: "vars-file" },
|
||||
});
|
||||
const configPath = args.config ?? "./config.toml";
|
||||
const configText = await Deno.readTextFile(configPath);
|
||||
export const cfg = configPath.toLowerCase().endsWith(".json")
|
||||
? JSON.parse(configText)
|
||||
: parseToml(configText);
|
||||
if (args.config) {
|
||||
console.debug(`Using config file: ${args.config}`);
|
||||
} else {
|
||||
console.debug(`Using default config file: ./config.toml`);
|
||||
}
|
||||
|
||||
const homeDir = Deno.env.get("HOME") || Deno.env.get("USERPROFILE");
|
||||
for (const config of cfg.settings) {
|
||||
config.asset_base ??= cfg.asset_base;
|
||||
config.variables = { ...(cfg.vars ?? {}), ...(config.variables ?? {}) };
|
||||
if (typeof args.from === "string" && args.from.length > 0) {
|
||||
const directPath = args.from;
|
||||
const publicationPath = `../../publications/${args.from}`;
|
||||
let directIsDirectory = false;
|
||||
try {
|
||||
directIsDirectory = (await Deno.stat(directPath)).isDirectory;
|
||||
} catch {
|
||||
// Treat non-path input as a publication version.
|
||||
}
|
||||
config.journal.from_directory = directIsDirectory
|
||||
? directPath
|
||||
: publicationPath;
|
||||
}
|
||||
if (config.journal.from_directory.startsWith("~/")) {
|
||||
config.journal.from_directory = config.journal.from_directory.replace(
|
||||
"~",
|
||||
homeDir || "",
|
||||
);
|
||||
}
|
||||
if (config.pdf?.signing?.enabled) {
|
||||
if (config.pdf.signing.key_path.startsWith("~/")) {
|
||||
config.pdf.signing.key_path = config.pdf.signing.key_path.replace(
|
||||
"~",
|
||||
homeDir || "",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (import.meta.main) {
|
||||
await match_sub_command_to_function(
|
||||
args._ as Array<string>,
|
||||
args,
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user