jcoglan / canopy

A parser compiler for Java, JavaScript, Python, Ruby
http://canopy.jcoglan.com
Mozilla Public License 2.0
420 stars 55 forks source link

Add -h and --help flags to the command line tool #62

Open koffie opened 2 years ago

koffie commented 2 years ago

I was trying to figure out what kind of options the command line tool has and my first instinct was just to add "-h" or "--help" to it like most command line tools would support however this just gives a very uninformative error message.

More general it would be nice to display a short usage message when supplying incorrect command line arguments

$ canopy -h           
The "to" argument must be of type string. Received undefined
TypeError [ERR_INVALID_ARG_TYPE]: The "to" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:372:5)
    at validateString (node:internal/validators:120:11)
    at relative (node:path:1192:5)
    at resolvePaths (/usr/local/lib/node_modules/canopy/bin/canopy:27:15)
    at main (/usr/local/lib/node_modules/canopy/bin/canopy:39:33)
    at run (/usr/local/lib/node_modules/canopy/bin/canopy:64:11)
    at Object.<anonymous> (/usr/local/lib/node_modules/canopy/bin/canopy:72:1)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)

$ canopy --help
The "to" argument must be of type string. Received undefined
TypeError [ERR_INVALID_ARG_TYPE]: The "to" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:372:5)
    at validateString (node:internal/validators:120:11)
    at relative (node:path:1192:5)
    at resolvePaths (/usr/local/lib/node_modules/canopy/bin/canopy:27:15)
    at main (/usr/local/lib/node_modules/canopy/bin/canopy:39:33)
    at run (/usr/local/lib/node_modules/canopy/bin/canopy:64:11)
    at Object.<anonymous> (/usr/local/lib/node_modules/canopy/bin/canopy:72:1)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)