var program = require('../')
, sinon = require('sinon').sandbox.create()
, should = require('should');
sinon.stub(process, 'exit');
sinon.stub(process.stdout, 'write');
program.command('mycommand [options]', 'this is my command');
program
.command('anothercommand [options]')
program.name.should.be.a.Function;
program.name().should.equal('test');
program.commands[0].name().should.equal('mycommand');
program.commands[0]._noHelp.should.be.false;
program.commands[0]._noHelp.should.be.false();
program.commands[1].name().should.equal('anothercommand');
program.commands[1]._noHelp.should.be.false;
program.commands[1]._noHelp.should.be.false();
program.commands[2].name().should.equal('hiddencommand');
program.commands[2]._noHelp.should.be.true;
program.commands[3].name().should.equal('hideagain');
program.commands[3]._noHelp.should.be.true;
program.commands[3]._noHelp.should.be.true();
program.commands[4].name().should.equal('help');
sinon.restore();
sinon.stub(process.stdout, 'write');
program.outputHelp();
process.stdout.write.calledOnce.should.be.true;
process.stdout.write.calledOnce.should.be.true();
process.stdout.write.args.length.should.equal(1);
var output = process.stdout.write.args[0];
sinon.restore();
output[0].should.containEql([
var expect = [
' Commands:',
'',
' mycommand [options] this is my command',
' anothercommand [options] ',
' anothercommand [options]',
' help [cmd] display help for [cmd]'
].join('\n'));
].join('\n');
output[0].indexOf(expect).should.not.be.equal(-1);