-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoke.js
More file actions
117 lines (97 loc) · 2.83 KB
/
poke.js
File metadata and controls
117 lines (97 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
'use strict';
import parse from './index.js';
const $ = console.log,
e = a => console.error('💥', a),
hr = '-'.repeat(42);
$(hr);
const poke = (title, argv, req) => {
$('🤓', title);
$('⌨️ ', argv.length, argv);
$('🔍', req);
const res = {}, ret = parse(argv, 0, req, res, e);
$('🎁', res);
$('😇', ret);
$(hr);
};
poke('give all to a bool', ['awawaw'], {
bool: { def: false, set: ['--'] },
}); // else if (typeof def !== 'boolean') _key = key, _exit = false;
poke('My key is two dashes but I dont know how to set', ['awawaw', 'sdfsdf'], {
'--': { def: [], set: null },
});
poke('super long dash', ['awawaw', '-----D', 'sdfsdf'], {
'--': { def: [], set: null },
'-----D': null
});
poke('Set Bool Get Chain Bomb', ['-bawawaw', 'sdfsdf'], {
bool: { def: false, set: ['--', '-b'] },
});
poke('Assign Bool', ['--b=awawaw', 'sdfsdf'], {
bool: { def: false, set: ['--', '--b'] },
});
poke('Assign Bool + Pool', ['--b=awawaw', 'sdfsdf'], {
bool: { def: false, set: ['--', '--b'] },
pool: { def: [], set: ['--', '--b'] },
}); // Overwritten all, which is expected behavior.
poke('Assign Pool + Bool', ['--b=awawaw', 'sdfsdf'], {
pool: { def: [], set: ['--', '--b'] },
bool: { def: false, set: ['--', '--b'] },
}); // bool only overwrites '--b', which is expected
poke('My New Home is in Random Place After a b', ['--b=awawaw', 'sdfsdf'], {
'--': null
});
poke('My New Home is in Random Place', ['awawaw', 'sdfsdf'], {
'--': null
});
poke('My New Home is after two Dashes', ['--', 'awawaw', 'sdfsdf'], {
'--': null
});
poke('My New Home is An Empty Bad Guy', ['awawaw', 'sdfsdf'], {
good: { def: [], set: '--' },
home: { set: '--' }
}); // if (def === undefined) continue;
poke('My set is undefined', ['awawaw', 'sdfsdf'], {
'--': { def: [], set: undefined }
});
poke('My set is null', ['awawaw', 'sdfsdf'], {
'--': { def: [], set: null }
});
poke('My exit is [null]', ['awawaw', 'sdfsdf'], {
'--': [null]
});
poke('My exit is [undefined]', ['awawaw', 'sdfsdf'], {
'--': [undefined]
}); // this is I said undefined acts like null in OptKit
poke('My Dashes are undefined', ['awawaw', 'sdfsdf'], {
'--': undefined
}); // Can't use undefined in ExitKit
poke('My Dashes are null', ['awawaw', 'sdfsdf'], {
'--': null
}); // But null is ok
poke('cannot exit within an argument && default named exit option', ['-abcd'], {
a: { def: false, set: '-a' },
b: '-b',
'-c': undefined,
'-d': null,
});
/*
🤓 cannot exit within an argument && default named exit option
⌨️ 1 [ '-abcd' ]
🔍 { a: { def: false, set: '-a' }, b: '-b', '-c': undefined, '-d': null }
💥 {
msg: 'cannot exit within an argument',
i: 0,
opt: '-b',
key: 'b',
val: undefined
}
💥 {
msg: 'invalid option',
i: 0,
opt: '-c',
key: undefined,
val: undefined
}
🎁 { a: true }
😇 { i: 1, key: '-d', opt: '-d' }
*/