1'use strict'; 2 3var parse = require('../'); 4var test = require('tape'); 5 6test('numeric short args', function (t) { 7 t.plan(2); 8 t.deepEqual(parse(['-n123']), { n: 123, _: [] }); 9 t.deepEqual( 10 parse(['-123', '456']), 11 { 1: true, 2: true, 3: 456, _: [] } 12 ); 13}); 14 15test('short', function (t) { 16 t.deepEqual( 17 parse(['-b']), 18 { b: true, _: [] }, 19 'short boolean' 20 ); 21 t.deepEqual( 22 parse(['foo', 'bar', 'baz']), 23 { _: ['foo', 'bar', 'baz'] }, 24 'bare' 25 ); 26 t.deepEqual( 27 parse(['-cats']), 28 { c: true, a: true, t: true, s: true, _: [] }, 29 'group' 30 ); 31 t.deepEqual( 32 parse(['-cats', 'meow']), 33 { c: true, a: true, t: true, s: 'meow', _: [] }, 34 'short group next' 35 ); 36 t.deepEqual( 37 parse(['-h', 'localhost']), 38 { h: 'localhost', _: [] }, 39 'short capture' 40 ); 41 t.deepEqual( 42 parse(['-h', 'localhost', '-p', '555']), 43 { h: 'localhost', p: 555, _: [] }, 44 'short captures' 45 ); 46 t.end(); 47}); 48 49test('mixed short bool and capture', function (t) { 50 t.same( 51 parse(['-h', 'localhost', '-fp', '555', 'script.js']), 52 { 53 f: true, p: 555, h: 'localhost', 54 _: ['script.js'], 55 } 56 ); 57 t.end(); 58}); 59 60test('short and long', function (t) { 61 t.deepEqual( 62 parse(['-h', 'localhost', '-fp', '555', 'script.js']), 63 { 64 f: true, p: 555, h: 'localhost', 65 _: ['script.js'], 66 } 67 ); 68 t.end(); 69}); 70