all_bool.js 756 B

123456789101112131415161718192021222324252627282930313233
  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. });