all_bool.js 675 B

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. var parse = require('../');
  3. var test = require('tape');
  4. test('flag boolean true (default all --args to boolean)', function (t) {
  5. var argv = parse(['moo', '--honk', 'cow'], {
  6. boolean: true,
  7. });
  8. t.deepEqual(argv, {
  9. honk: true,
  10. _: ['moo', 'cow'],
  11. });
  12. t.deepEqual(typeof argv.honk, 'boolean');
  13. t.end();
  14. });
  15. test('flag boolean true only affects double hyphen arguments without equals signs', function (t) {
  16. var argv = parse(['moo', '--honk', 'cow', '-p', '55', '--tacos=good'], {
  17. boolean: true,
  18. });
  19. t.deepEqual(argv, {
  20. honk: true,
  21. tacos: 'good',
  22. p: 55,
  23. _: ['moo', 'cow'],
  24. });
  25. t.deepEqual(typeof argv.honk, 'boolean');
  26. t.end();
  27. });