You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried using minimist to write a command line tool that accepts a latitude and longitude, but I ran into a problem when one of the values is negative. You can see the issue by simply dumping the parsed arguments, like this:
// dump.js
var argv = require("minimist")(process.argv.slice(2));
console.log(JSON.stringify(argv, null, 2));
Arguments which start with a dash are assumed to be options and not used as option-values.
The work-around is to be explicit and embed the option value in the argument with an = like:
nodedump.js--lat=34.0168729--long=-118.3459323
I tried quoting the negative value, but this did not help.
As a side-note on why this did not work, quotes around an argument are usually removed by the shell before they reach node and minimist. Quotes can help with special shell characters like $ in arguments, and with spaces within an argument, but don't help with how - is processed.
I tried using minimist to write a command line tool that accepts a latitude and longitude, but I ran into a problem when one of the values is negative. You can see the issue by simply dumping the parsed arguments, like this:
Try running this:
node dump.js --lat 34.0168729 --long -118.3459323
Since the longitude is negative, it starts with a "-", so apparently it is being interpreted as a new argument. The output looks like this:
I expected that to be:
I tried quoting the negative value, but this did not help.
The text was updated successfully, but these errors were encountered: