Keyang / node-csvtojson

Blazing fast and Comprehensive CSV Parser for Node.JS / Browser / Command Line.
MIT License
2.02k stars 270 forks source link

Confusing command-line parsing for --noheader #359

Open kevinoid opened 4 years ago

kevinoid commented 4 years ago

Thanks for creating and maintaining this package, it looks very useful! Just a small suggestion from a newcomer who had a rather bumpy time getting started. I tried:

$ csvtojson --noheader file.csv
Unknown boolean value  for parameter --noheader.
[... 33 lines of helptext ]

So then I tried

$ csvtojson --noheader true file.csv
Unknown boolean value  for parameter --noheader.
[... 33 lines of helptext ]

At this point I dug into the source and found that the accepted syntax is

$ csvtojson --noheader=true file.csv

Is there any chance you might consider making the option parsing compatible with getopt_long(3) (possibly by using a library like minimist, yargs, or commander)? If not, perhaps a clearer error message? Maybe also reducing the amount of helptext shown so errors fit on a 80x24 terminal?

Thanks for considering, Kevin

jfoclpf commented 2 years ago

The docs are very clear IMHO

https://github.com/Keyang/node-csvtojson#header-row

kevinoid commented 2 years ago

@jfoclpf I don't see anything in the docs you linked about the command-line option parsing this issue describes (--noheader vs --noheader true vs --noheader=true). Even if it were documented, I would argue it is better to follow the getopt parsing conventions users are likely to expect rather than documenting non-standard conventions.

jfoclpf commented 2 years ago

you're right, I read it too quickly