node-csvtojson icon indicating copy to clipboard operation
node-csvtojson copied to clipboard

Confusing command-line parsing for --noheader

Open kevinoid opened this issue 6 years ago • 3 comments

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

kevinoid avatar Jan 24 '20 22:01 kevinoid

The docs are very clear IMHO

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

jfoclpf avatar Feb 10 '22 13:02 jfoclpf

@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.

kevinoid avatar Feb 10 '22 14:02 kevinoid

you're right, I read it too quickly

jfoclpf avatar Feb 10 '22 16:02 jfoclpf