Closed stevegeek closed 13 years ago
So basically the idea was the following:
Does this do that? If so, I will take it in.
Also (just looking at your second commit). The idea is that grammar and input can't BOTH be stdin
Oops, didn't mean to close this
1) yes 2) yes 3) no , will update it later
Oh btw, '-i -' is not parsed by nomnom if im not mistaken, it assumes the extra '-' on the command line is the start of a new command i think, so in this case the value of the input option is as below:
cmd -i - -t
then input === true
cmd -t -i -
then input === true
cmd -i -t
then input === true
cmd -i file
then input === 'file'
cmd -t -i
then input === '' <- the odd one out
Will think about it more later when I have time
Ok now the examples in 1) 2) and 3) should all work as expected
eg
echo 'start="a"' | node lib/language/cli.js -t -g languages/JavaScript.language -o out.txt
-> out to file, input from stdin
node lib/language/cli.js -t -g languages/JavaScript.language
-> out to stdout
echo 'start="a"' | node lib/language/cli.js -t
-> grammar from stdin , out to stdout
echo 'start="a"' | node lib/language/cli.js -t -g languages/JavaScript.language -i
-> input from stdin
Ah one sec, seen something I think
Ok think that works, sorry about all the commits!
@tolmasky have you had a chance to look further at this? I think it fulfills the requirement. I have been using it for a few days and seems fine
Yeah sorry I haven't gotten to this yet, just been super busy. I will try to get it merged in tonight.
No probs, no rush
I really dislike asynchronous IO for command line apps.
Ah ok, sorry about that
nothing to apologize for, your thing works exactly as described.
Makes read/writes async and also adds some error checking.
Now for CLI if: '-i' is specified without a parameter it defaults to stdin, if it is omitted no input is assumed. '-o' is specified without parameter or omitted then defaults to stdout '-g' is specified without a parameter or omitted defaults to stdin, (and if both input and grammar are from stdin then they are accepted in sequence, first grammar is input then 'input' )
I have tested it generally but this should be further tested by someone who can def verify output is correct.
Feedback/more testing/changes/hate/love welcome