|
1 | 1 | #!/bin/env node |
2 | 2 |
|
3 | | -var argv = require('optimist') |
4 | | - .boolean('cors') |
5 | | - .boolean('v') |
6 | | - .boolean('live') |
7 | | - .argv; |
| 3 | +var argv = require('nomnom') |
| 4 | + .option('verbose', { |
| 5 | + abbr: 'v', |
| 6 | + flag: true, |
| 7 | + help: 'Print the logs to console' |
| 8 | + }) |
| 9 | + .option('version', { |
| 10 | + flag: true, |
| 11 | + help: 'Print current ldnode version', |
| 12 | + callback: function () { |
| 13 | + fs.readFile(path.resolve(__dirname, '../package.json'), 'utf-8', function(err, file) { |
| 14 | + console.log(JSON.parse(file).version); |
| 15 | + }); |
| 16 | + } |
| 17 | + }) |
| 18 | + .option('uriBase', { |
| 19 | + full: 'uri', |
| 20 | + abbr: 'u', |
| 21 | + metavar: 'URI', |
| 22 | + help: 'Default address of the server (e.g. http[s]://host:port/path)' |
| 23 | + }) |
| 24 | + .option('fileBase', { |
| 25 | + abbr: 'b', |
| 26 | + metavar: 'PATH', |
| 27 | + full: 'path', |
| 28 | + help: 'Base location to serve resources' |
| 29 | + }) |
| 30 | + .option('port', { |
| 31 | + abbr: 'p', |
| 32 | + help: 'Port to use' |
| 33 | + }) |
| 34 | + .option('cache', { |
| 35 | + abbr: 'c', |
| 36 | + help: 'Set cache time (in seconds), 0 for no cache' |
| 37 | + }) |
| 38 | + .option('noSsl', { |
| 39 | + help: 'Run ldnode with without ssl, so in http', |
| 40 | + full: 'no-ssl', |
| 41 | + flag: true |
| 42 | + }) |
| 43 | + .option('sslKey', { |
| 44 | + help: 'Path to the ssl key', |
| 45 | + abbr: 'K', |
| 46 | + full: 'ssl-key' |
| 47 | + }) |
| 48 | + .option('ssl-cert', { |
| 49 | + help: 'Path to the ssl cert', |
| 50 | + abbr: 'C' |
| 51 | + }) |
| 52 | + .option('noWebid', { |
| 53 | + help: 'Path to the ssl key', |
| 54 | + full: 'no-webid', |
| 55 | + flag: true |
| 56 | + }) |
| 57 | + .option('webidKey', { |
| 58 | + help: 'Path to the webid key', |
| 59 | + full: 'webid-key', |
| 60 | + abbr: 'k' |
| 61 | + }) |
| 62 | + .option('webidCert', { |
| 63 | + help: 'Path to the webid cert', |
| 64 | + full: 'webid-cert', |
| 65 | + abbr: 'c' |
| 66 | + }) |
| 67 | + .parse(); |
8 | 68 |
|
9 | | -if (argv.h || argv.help || argv['?']) { |
10 | | - console.log([ |
11 | | - "usage: ldnode [path] [options]", |
12 | | - "", |
13 | | - "options:", |
14 | | - " --uriBase Address, port, and default path of the server. (Example: http://localhost:3000/test/)", |
15 | | - " --fileBase Base location to serve resources. Requests whose paths do not have fileBase as a prefix will be ignored", |
16 | | - " --live Offer and support live updates", |
17 | | - " -p Port to use", |
18 | | - " -v Log messages to console", |
19 | | - " --changesSuffix The suffix that will be used to identify the requests that will subscribe to changes to the object requested. Defaults to ,changes", |
20 | | - " --cors Enable CORS via the 'Access-Control-Allow-Origin' header", |
21 | | - " -c Set cache time (in seconds). e.g. -c10 for 10 seconds.", |
22 | | - " To disable caching, use -c-1.", |
23 | | - " --changesSuffix sss Change the URI suffix used for the URI of a change stream", |
24 | | - " --SSESuffix sss Change the URI suffix used for the URI of a SSE stream", |
25 | | - "", |
26 | | - " -S --ssl Enable https.", |
27 | | - " -C --cert Path to ssl cert file (default: cert.pem).", |
28 | | - " -K --key Path to ssl key file (default: key.pem).", |
29 | | - "", |
30 | | - " --webid Enable WebID authentication", |
31 | | - " --privateKey Path to the private key used to enable webid authentication", |
32 | | - " --cert Path to the private key used to enable webid authentication", |
33 | | - " -h --help Print this list and exit." |
34 | | - ].join('\n')); |
35 | | - process.exit(); |
36 | | -} |
37 | | - |
38 | | -process.env.DEBUG = argv.v ? 'ldnode:*' : false; |
| 69 | +argv.webid = !argv.noWebid; |
| 70 | +process.env.DEBUG = argv.verbose ? 'ldnode:*' : false; |
39 | 71 | var debug = require('../logging').server; |
40 | 72 | var ldnode = require('../index'); |
41 | 73 |
|
|
0 commit comments