Closed sbstp closed 9 years ago
Thank you for this contribution :)
Hi @SBSTP
I decided to make use of your options parser in the turing-turtle example program just to dogfood it a little bit.
I've run into some minor issues and have some suggestions for improvements.
./higgs ../examples/turing-turtle.js -- -w 200 -h 200
TypeError: call to non-function "charCodeAt" RegExpContext(1B9F0) ("stdlib/regexp.js"@980:28) RegExp_prototype_test(1C281) ("stdlib/regexp.js"@2675:19) testIntPositive(7759D) ("lib/options.js"@326:16) Options_prototype_parse(776E6) ("lib/options.js"@454:22) ___examples_turing_turtle_js(22AEF) ("../examples/turing-turtle.js"@275:12)
var Options = require('lib/options').Options;
It seems to me that there isn't really much of a use case for having multiple options parsers though? Maybe require('lib/options') should produce a "singleton" option parser, avoiding the need to instantiate one. Let me know what you think.
options.add({name: 'width', type: '+int', shortname:'w', desc:'canvas width'});
I'm aware that you already have a syntax to add many options at once this way. I think that .add() should probably work this way as well.
Ok I found why it doesn't work. The format is
./higgs ../examples/turing-turtle.js -- -w=200 -h=200
^ ^
Using spaces makes the parser much more complex and creates ambiguities as to what is an option value and what's a plain argument, hence why I used =
. Still though, the parser shouldn't crash because of that.
Yes, no complaints on the use of equals, I prefer it this way also. It's only the crashing that seemed an issue.
Yes, I fixed it now, it yields a type error. I'm working on the API changes.
Btw, JS also has a SyntaxError: https://github.com/higgsjs/Higgs/blob/master/source/stdlib/error.js#L135