The result (code here) is a small program with some options:
Options:
-h, --help output usage information
-V, --version output the version number
-o <path> File to write data to
-c <path> File to print
-t <string> Text to print
-d <string> Data to write to file
-v <string> Verbosity: DEBUG, INFO, LOG, WARN or ERROR
I made a custom logger and a program to parse passed arguments. The option to parse with the commander module, as seen here:var program = require(commander);
program.parse(process.argv);
which is used in the quickscrape
code as well, didn't really work for me. Maybe I did something wrong. When I run the following codevar program = require('commander');
program
.option('-t',
'Test A')
.option('-T',
'Test B')
.parse(process.argv);
console.log(program);
like thisnode file.js -t 'Test_A' -T 'Test_B'
the console outputs this:{ commands: [],
options:
[ { flags: '-t',
required: 0,
optional: 0,
bool: true,
long: '-t',
description: 'Test A' },
{ flags: '-T',
required: 0,
optional: 0,
bool: true,
long: '-T',
description: 'Test B' } ],
_execs: {},
_allowUnknownOption: false,
_args: [],
_name: 'file',
Command: [Function: Command],
Option: [Function: Option],
_events: { '-t': [Function], '-T': [Function] },
rawArgs:
[ 'node',
'/home/larsw/public_html/cm-repo/js/file.js',
'-t',
'Test_A',
'-T',
'Test_B' ],
T: true,
args: [ 'Test_A', 'Test_B' ] }
This doesn't seem right to me. If is understand correctly, 'Test_A'
is passed to -t
and 'Test_B'
to -T
. Instead, commander
seems to say -t
and/or -T
passed (T: true
is present when you pass only -t
too), and two strings are passed without context. Maybe there's something wrong with the program.option()
things. Maybe my knowledge about command line arguments is incorrect, but I don't think to this extent. Just the same, I made a parser myself. Not sure if it follows any standard, but it works for me, for now. I will update the documentation shortly.Next week I'll look into
norma
to see how it changes the format of papers from XML/HTML to sHTML, and ChemicalTagger to see how it recognises sentences.
No comments:
Post a Comment