felixSchl/neodoc

Provide a means to error/exit manually post parse

felixSchl opened this issue · 0 comments

Currently only a failed argv parse will print the error and the short help. There ought to be a way for users to fail post-mortem using the same format.

For example:

const argv = neodoc.run(`usage: cp <from> <to>`);
if (!fs.existsSync(argv['<from>'])) {
  neodoc.exit(`file does not exist: ${argv['<from>']}`);
}

should somehow print:

> ./cp some-file.txt
cp: file does not exist: some-file.txt

The only quirk here is that the program name needs to be known. So either it must be stored in argv, maybe as some reserved property and passed manually to neodoc.exit, or ... ?