Buslowicz / twc

TypeScript based, boilerplate-less, Polymer toolbox friendly Polymer Modules
32 stars 1 forks source link

Improve handling of command line arguments #64

Closed tpluscode closed 7 years ago

tpluscode commented 7 years ago

First of all, I see that the argument names style changed from kebab to camel?

--out-dir -> --outDir

I prefer kebab but that's beside the point.

The real issue is that when I give twc an invalid parameter (such as the previously valid --out-dir), the process still proceeds. IMO it should fail and display a message that there was an invalid parameter. Otherwise the result may be surprising.

Are you parsing the arguments manually? I don't know about node, but maybe you could use some kind of library to simplify reading, parsing and validating input parameters? Such lib would likely also generate the help text automatically.

Buslowicz commented 7 years ago

I moved to camelCase to make it closer to tsc options. As for lib, I'm using commander, see the cli.ts file to check how is it done. Don't know if there is an option to fail on incorrect options. I'll give it a read and if possible I'll throw that error. If it's not provided by commander, I'll try doing it manually or will replace commander with something else.

tpluscode commented 7 years ago

This is not yet supported apparently: tj/commander.js#482

This looks like a viable alternative: https://www.npmjs.com/package/command-line-args

Buslowicz commented 7 years ago

Affirmative. I will take a look into it and make sure it throws an error when incorrect option is passed (using lib you mentioned if it has all the other features).