#!/usr/bin/env node `use strict`; const os = require('os'), path = require('path'); const process = require('process'); const docserv = require('.'); function main(){ function do_help(){ let txt = ` Usage: docset_server.js --docsets /path/to/docset/dir --port 8080 This is a very simple docset viewer. Docsets are sqlite3 files containing a search index and a directory structure of HTML files. They are used for reading technical documentation offline. You can read more about them here: https://kapeli.com/docsets One or more "docset directories" can exist in your ~/.docset directory. If you have the Zeal program installed, the command below will allow you to use the same docset files: ln -s .local/share/Zeal/Zeal/docsets .docset The parameters --port and --docsets are used to override the defaults. `; console.log(txt); } let args = process.argv.slice(2); /* port: 8080, docset: path.join(os.homedir(), ".docset") */ let opt = { }; while(args.length){ let arg = args.shift(); switch(arg){ case '--port': opt.port = parseInt(args.shift()); break; case '--docsets': opt.docset = args.shift(); break; default: do_help(); return(1); break; } } console.log(opt); docserv.start_server(opt); } main();