2025-05-12 05:38:44 +09:00

68 lines
2.5 KiB
JavaScript

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const options_1 = __importDefault(require("./options"));
const getBook_1 = __importDefault(require("./getBook"));
const parse_1 = __importDefault(require("../parse"));
function printBook(book) {
const logger = book.getLogger();
const config = book.getConfig();
const configFile = config.getFile();
const summary = book.getSummary();
const summaryFile = summary.getFile();
const readme = book.getReadme();
const readmeFile = readme.getFile();
const glossary = book.getGlossary();
const glossaryFile = glossary.getFile();
if (configFile.exists()) {
logger.info.ln("Configuration file is", configFile.getPath());
}
if (readmeFile.exists()) {
logger.info.ln("Introduction file is", readmeFile.getPath());
}
if (glossaryFile.exists()) {
logger.info.ln("Glossary file is", glossaryFile.getPath());
}
if (summaryFile.exists()) {
logger.info.ln("Table of Contents file is", summaryFile.getPath());
}
}
function printMultingualBook(book) {
const logger = book.getLogger();
const languages = book.getLanguages();
const books = book.getBooks();
logger.info.ln(`${languages.size} languages`);
const file = languages.getFile();
const list = languages.getList();
list.valueSeq().forEach((lang) => {
logger.info.ln("Language:", lang.getTitle());
printBook(books.get(lang.getID()));
logger.info.ln("");
});
}
exports.default = {
name: "parse [book]",
description: "parse and print debug information about a book",
options: [options_1.default.log],
exec: function (args, kwargs) {
const book = (0, getBook_1.default)(args, kwargs);
const logger = book.getLogger();
return parse_1.default.parseBook(book).then((resultBook) => {
const rootFolder = book.getRoot();
const contentFolder = book.getContentRoot();
logger.info.ln("Book located in:", rootFolder);
if (contentFolder != rootFolder) {
logger.info.ln("Content located in:", contentFolder);
}
if (resultBook.isMultilingual()) {
printMultingualBook(resultBook);
}
else {
printBook(resultBook);
}
});
}
};