harthur / nomnom

Option parser for node with generated usage and commands
MIT License
470 stars 62 forks source link

Required positional arguments are not checked #45

Open orospakr opened 10 years ago

orospakr commented 10 years ago

However, their indication with <param> rather than [param] does still work.

#!/usr/bin/env node

var nomnom = require("nomnom");

nomnom.command("go")
    .help("Do a thing")
    .options({
        "important": {position: 0, required: true, help: "I'm required!"}
    });

nomnom.parse();
./script.js go # prints no error
madebyherzblut commented 9 years ago

I just ran into this as well and it seems that the command is at position 0. So if you use position 1 it works as expected:

#!/usr/bin/env node

var nomnom = require("nomnom");

nomnom.command("go")
    .help("Do a thing")
    .options({
        "important": {position: 1, required: true, help: "I'm required!"}
    });

nomnom.parse();