summaryrefslogtreecommitdiffstats
path: root/lib/cli/parse.js
diff options
context:
space:
mode:
authorSamy Pesse <samypesse@gmail.com>2016-04-26 15:23:28 +0200
committerSamy Pesse <samypesse@gmail.com>2016-04-26 15:23:28 +0200
commitfa17f1671685a97e88c84fdba6a94744c54a09b8 (patch)
tree63083c0645a1f88bc7e96d891ef9ec9509d7680a /lib/cli/parse.js
parentce99c8c7061eb9b4a2a5f4ff534d7fbeaf37cad0 (diff)
downloadgitbook-fa17f1671685a97e88c84fdba6a94744c54a09b8.zip
gitbook-fa17f1671685a97e88c84fdba6a94744c54a09b8.tar.gz
gitbook-fa17f1671685a97e88c84fdba6a94744c54a09b8.tar.bz2
Add base for commands
Improve plugins installation
Diffstat (limited to 'lib/cli/parse.js')
-rw-r--r--lib/cli/parse.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/lib/cli/parse.js b/lib/cli/parse.js
new file mode 100644
index 0000000..0421b3e
--- /dev/null
+++ b/lib/cli/parse.js
@@ -0,0 +1,68 @@
+var options = require('./options');
+var getBook = require('./getBook');
+
+var Parse = require('../parse');
+
+function printBook(book) {
+ var logger = book.getLogger();
+
+ var config = book.getConfig();
+ var configFile = config.getFile();
+
+ var summary = book.getSummary();
+ var summaryFile = summary.getFile();
+
+ var readme = book.getReadme();
+ var readmeFile = readme.getFile();
+
+ var glossary = book.getGlossary();
+ var 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());
+ }
+
+ //logger.info.ln('Table of Contents:');
+}
+
+
+module.exports = {
+ name: 'parse [book]',
+ description: 'parse and print debug information about a book',
+ options: [
+ options.log
+ ],
+ exec: function(args, kwargs) {
+ var book = getBook(args, kwargs);
+ var logger = book.getLogger();
+
+ return Parse.parseBook(book)
+ .then(function(resultBook) {
+ var rootFolder = book.getRoot();
+ var contentFolder = book.getContentRoot();
+
+ logger.info.ln('Book located in:', rootFolder);
+ if (contentFolder != rootFolder) {
+ logger.info.ln('Content located in:', contentFolder);
+ }
+
+ if (resultBook.isMultilingual()) {
+
+ } else {
+ printBook(resultBook);
+ }
+ });
+ }
+};