all_bool.js 756 B

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