-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
131 lines (124 loc) · 3.07 KB
/
index.js
File metadata and controls
131 lines (124 loc) · 3.07 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env node
const yargs = require('yargs');
const diffScript = require('./scripts/diff');
const csvScript = require('./scripts/csv');
yargs.usage('$0 <cmd> [args]');
yargs.command(
'diff <leftURL> <rightURL> [options]',
'diffs the json response of two URLs.',
{
output: {
alias: 'o',
describe: 'print the output to a CSV file',
type: 'string',
},
quiet: {
alias: 'q',
describe: 'silences the console output',
type: 'boolean',
default: false,
},
failOnDiff: {
alias: 'f',
default: false,
describe: 'return exit code 1 if there is a difference',
type: 'boolean',
},
expectedStatusCode: {
describe: 'expected status codes of the requests',
type: 'string',
},
customCompare: {
describe: 'custom compare json as string',
type: 'string',
},
method: {
alias: 'm',
default: 'GET',
describe: 'request method (GET, POST, or DELETE)',
type: 'string',
},
diffheaders: {
alias: 'x',
default: false,
describe: 'diff the headers as well as the body',
type: 'boolean',
},
sortKey: {
alias: 'k',
describe: 'sort any array of json objects by the specified key',
type: 'string',
},
sortKeys: {
alias: 'K',
describe: 'multiple sort keys. separate multiple keys with a space: -K "id" "userId"',
type: 'array',
},
timeout: {
alias: 't',
describe: 'timeout for requests. defaults to 5 seconds',
default: 5000,
type: 'number',
},
skipcertificate: {
alias: 'c',
describe: 'skip checking of https certificates',
type: 'string',
},
headers: {
alias: 'H',
describe:
'attach a header to the request. separate multiple headers with a space: -H "Accept: text/plain" "Accept-Charset: utf-8"',
type: 'array',
},
ignore: {
alias: 'i',
describe: 'ignore the provided key(s). separate multiple keys with a space: -i "key1" "key2"',
type: 'array',
},
body: {
alias: 'b',
describe:
'request body (only for POST) separate multiple body parts with a space: -b "username: testing" "password: 123"',
type: 'array',
},
arraysortkey: {
alias: 'a',
describe: 'sort nested arrays by the sort key, defaults to id',
type: 'string',
},
},
diffScript,
);
yargs.command(
'csv <path> [options]',
'diffs all urls in a csv file',
{
output: {
alias: 'o',
describe: 'print the output to a CSV file',
type: 'string',
},
sleep: {
alias: 's',
default: 0,
describe: 'sleep before every request (in milliseconds)',
type: 'number',
},
diffheaders: {
alias: 'x',
default: false,
describe: 'diff the headers as well as the body',
type: 'boolean',
},
timeout: {
alias: 't',
describe: 'timeout for requests. defaults to 5 seconds',
default: 5000,
type: 'number',
},
},
csvScript,
);
yargs.help();
yargs.argv; // eslint-disable-line