tj / commander.js

node.js command-line interfaces made easy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compatible with deno

tch1121 opened this issue · comments

commented

Don't ignore the first two argv

program.parse(Deno.args);

I now use it like this

program.parse(["null", "null", ...Deno.args]);

Deno have done a great job of filling out node compatibility so Commander works out of the box.

I found three approaches you might use:

  1. the modern Commander way, leave it to Commander (and the Deno node compatibility):
program.parse();
  1. if you want to use Deno.args then .parse() supports a second parameter to indicate the argument conventions:
program.parse(Deno.args, { from: 'user' });
  1. or you could use the compatibility layer explicitly
import * as process from 'node:process';
program.parse(process.argv);
commented

thank you for your work