curlie 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -29
- package/bin/index.js +1 -1
- package/lib/utils.js +37 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# curlie
|
|
2
2
|
|
|
3
3
|
A curl-like CLI tool for Node.js - transfer data from HTTP, HTTPS, FTP servers and local files.
|
|
4
4
|
|
|
@@ -11,9 +11,9 @@ npm install -g curlie
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
curlie [options] <url>
|
|
15
|
+
curlie ftp://<host>/<path>
|
|
16
|
+
curlie file://<path>
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Options
|
|
@@ -96,96 +96,96 @@ nodecurl file://<path>
|
|
|
96
96
|
|
|
97
97
|
```bash
|
|
98
98
|
# Simple GET request
|
|
99
|
-
|
|
99
|
+
curlie https://example.com
|
|
100
100
|
|
|
101
101
|
# With SSL skip (insecure)
|
|
102
|
-
|
|
102
|
+
curlie -k https://example.com
|
|
103
103
|
|
|
104
104
|
# POST with data
|
|
105
|
-
|
|
105
|
+
curlie -X POST -d "name=test&value=123" https://api.example.com
|
|
106
106
|
|
|
107
107
|
# POST with JSON
|
|
108
|
-
|
|
108
|
+
curlie --json '{"name":"test"}' https://api.example.com
|
|
109
109
|
```
|
|
110
110
|
|
|
111
111
|
### File Downloads
|
|
112
112
|
|
|
113
113
|
```bash
|
|
114
114
|
# Save to specific file
|
|
115
|
-
|
|
115
|
+
curlie -o page.html https://example.com/page
|
|
116
116
|
|
|
117
117
|
# Save with remote filename
|
|
118
|
-
|
|
118
|
+
curlie -O https://example.com/file.txt
|
|
119
119
|
|
|
120
120
|
# Save to directory
|
|
121
|
-
|
|
121
|
+
curlie --output-dir ./downloads https://example.com/file
|
|
122
122
|
```
|
|
123
123
|
|
|
124
124
|
### Headers & Cookies
|
|
125
125
|
|
|
126
126
|
```bash
|
|
127
127
|
# Custom headers
|
|
128
|
-
|
|
128
|
+
curlie -H "Authorization: Bearer token" https://api.example.com
|
|
129
129
|
|
|
130
130
|
# Custom User-Agent
|
|
131
|
-
|
|
131
|
+
curlie -A "MyBot/1.0" https://example.com
|
|
132
132
|
|
|
133
133
|
# Save cookies
|
|
134
|
-
|
|
134
|
+
curlie -c cookies.txt https://example.com
|
|
135
135
|
|
|
136
136
|
# Send cookies
|
|
137
|
-
|
|
137
|
+
curlie -b cookies.txt https://example.com
|
|
138
138
|
```
|
|
139
139
|
|
|
140
140
|
### Redirects
|
|
141
141
|
|
|
142
142
|
```bash
|
|
143
143
|
# Follow redirects (default)
|
|
144
|
-
|
|
144
|
+
curlie -L https://example.com/redirect
|
|
145
145
|
|
|
146
146
|
# Limit redirects
|
|
147
|
-
|
|
147
|
+
curlie -L --max-redirs 3 https://example.com/redirect
|
|
148
148
|
```
|
|
149
149
|
|
|
150
150
|
### FTP
|
|
151
151
|
|
|
152
152
|
```bash
|
|
153
153
|
# List directory
|
|
154
|
-
|
|
154
|
+
curlie ftp://ftp.example.com/
|
|
155
155
|
|
|
156
156
|
# Download file
|
|
157
|
-
|
|
157
|
+
curlie -o local.txt ftp://ftp.example.com/file.txt
|
|
158
158
|
|
|
159
159
|
# Upload file
|
|
160
|
-
|
|
160
|
+
curlie -T local.txt ftp://ftp.example.com/upload/
|
|
161
161
|
```
|
|
162
162
|
|
|
163
163
|
### Advanced
|
|
164
164
|
|
|
165
165
|
```bash
|
|
166
166
|
# Custom DNS resolve
|
|
167
|
-
|
|
167
|
+
curlie --resolve example.com:443:127.0.0.1 https://example.com
|
|
168
168
|
|
|
169
169
|
# DNS-over-HTTPS
|
|
170
|
-
|
|
170
|
+
curlie --doh-url https://dns.google/resolve https://example.com
|
|
171
171
|
|
|
172
172
|
# Speed limit
|
|
173
|
-
|
|
173
|
+
curlie --limit-rate 1M https://example.com/large-file
|
|
174
174
|
|
|
175
175
|
# Parallel downloads
|
|
176
|
-
|
|
176
|
+
curlie -Z url1 url2 url3
|
|
177
177
|
|
|
178
178
|
# Verbose output
|
|
179
|
-
|
|
179
|
+
curlie -v https://example.com
|
|
180
180
|
```
|
|
181
181
|
|
|
182
182
|
## Help
|
|
183
183
|
|
|
184
184
|
```bash
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
curlie -h # Show all options
|
|
186
|
+
curlie http -h # HTTP options only
|
|
187
|
+
curlie ftp -h # FTP options only
|
|
188
|
+
curlie dns -h # DNS options only
|
|
189
189
|
```
|
|
190
190
|
|
|
191
191
|
## Exit Codes
|
package/bin/index.js
CHANGED
|
@@ -26,7 +26,7 @@ if (flags.user === undefined) flags.user = "anonymous:anonymous";
|
|
|
26
26
|
|
|
27
27
|
const main = async () => {
|
|
28
28
|
if (!url && !flags.help && !flags.parallel) {
|
|
29
|
-
console.log("Error: Usage:
|
|
29
|
+
console.log("Error: Usage: curlie [options] <url>");
|
|
30
30
|
process.exitCode = 1;
|
|
31
31
|
return;
|
|
32
32
|
}
|
package/lib/utils.js
CHANGED
|
@@ -210,18 +210,18 @@ export function bufferResponse(res, flags, resolve) {
|
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
export function showHelp(module) {
|
|
213
|
-
const synopsis = `Usage:
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
const synopsis = `Usage: curlie [options] <url>
|
|
214
|
+
curlie ftp://<host>/<path>
|
|
215
|
+
curlie file://<path>`;
|
|
216
216
|
|
|
217
217
|
const examples = `Examples:
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
218
|
+
curlie -k https://example.com
|
|
219
|
+
curlie -o file.html https://example.com/file
|
|
220
|
+
curlie -L https://example.com/redirect
|
|
221
|
+
curlie -d "name=value" https://example.com/post
|
|
222
|
+
curlie -X POST -d '{"json":"data"}' https://api.example.com
|
|
223
|
+
curlie -c cookies.txt -b cookies.txt https://example.com
|
|
224
|
+
curlie --resolve example.com:443:127.0.0.1 https://example.com`;
|
|
225
225
|
|
|
226
226
|
if (!module) {
|
|
227
227
|
console.log(synopsis);
|
|
@@ -269,7 +269,7 @@ ${examples}
|
|
|
269
269
|
|
|
270
270
|
switch (module) {
|
|
271
271
|
case "ftp":
|
|
272
|
-
console.log(`Usage:
|
|
272
|
+
console.log(`Usage: curlie ftp [options] ftp://<host>/<path>
|
|
273
273
|
|
|
274
274
|
Options:
|
|
275
275
|
-u, --user <user:password> Authentication
|
|
@@ -284,13 +284,13 @@ Options:
|
|
|
284
284
|
-v, --verbose Show protocol details
|
|
285
285
|
|
|
286
286
|
Examples:
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
curlie -l ftp://ftp.example.com/
|
|
288
|
+
curlie -o file.txt ftp://ftp.example.com/file.txt
|
|
289
|
+
curlie -T local.txt ftp://ftp.example.com/upload/`);
|
|
290
290
|
break;
|
|
291
291
|
|
|
292
292
|
case "http":
|
|
293
|
-
console.log(`Usage:
|
|
293
|
+
console.log(`Usage: curlie [options] <url>
|
|
294
294
|
|
|
295
295
|
Options:
|
|
296
296
|
-X, --request <method> HTTP method (GET, POST, PUT, DELETE, etc)
|
|
@@ -310,24 +310,24 @@ Options:
|
|
|
310
310
|
--limit-rate <speed> Limit speed
|
|
311
311
|
|
|
312
312
|
Examples:
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
313
|
+
curlie https://example.com
|
|
314
|
+
curlie -X POST -d "name=test" https://api.example.com
|
|
315
|
+
curlie -H "Authorization: Bearer token" https://api.example.com
|
|
316
|
+
curlie -L https://example.com/redirect
|
|
317
|
+
curlie -c cookies.txt -b cookies.txt https://example.com`);
|
|
318
318
|
break;
|
|
319
319
|
|
|
320
320
|
case "file":
|
|
321
|
-
console.log(`Usage:
|
|
321
|
+
console.log(`Usage: curlie file://<path>
|
|
322
322
|
|
|
323
323
|
Options:
|
|
324
324
|
-H, --head Show file info (size, modified date)
|
|
325
325
|
-T, --upload Write to local file
|
|
326
326
|
|
|
327
327
|
Examples:
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
328
|
+
curlie file:///home/user/test.txt
|
|
329
|
+
curlie -H file:///home/user/test.txt
|
|
330
|
+
curlie -T source.txt file:///dest.txt`);
|
|
331
331
|
break;
|
|
332
332
|
|
|
333
333
|
case "output":
|
|
@@ -344,9 +344,9 @@ Examples:
|
|
|
344
344
|
--create-file-mode <mode> File permissions
|
|
345
345
|
|
|
346
346
|
Examples:
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
347
|
+
curlie -o page.html https://example.com
|
|
348
|
+
curlie -O https://example.com/file.txt
|
|
349
|
+
curlie --output-dir ./downloads https://example.com/`);
|
|
350
350
|
break;
|
|
351
351
|
|
|
352
352
|
case "connection":
|
|
@@ -363,10 +363,10 @@ Examples:
|
|
|
363
363
|
--retry-delay <seconds> Delay between retries
|
|
364
364
|
|
|
365
365
|
Examples:
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
366
|
+
curlie --limit-rate 1M https://example.com/file
|
|
367
|
+
curlie --max-time 60 https://example.com
|
|
368
|
+
curlie -Z url1 url2 url3
|
|
369
|
+
curlie --retry 3 https://unreliable.example.com`);
|
|
370
370
|
break;
|
|
371
371
|
|
|
372
372
|
case "dns":
|
|
@@ -378,15 +378,15 @@ Examples:
|
|
|
378
378
|
-6, --ipv6 IPv6 only
|
|
379
379
|
|
|
380
380
|
Examples:
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
381
|
+
curlie --resolve example.com:443:127.0.0.1 https://example.com
|
|
382
|
+
curlie --dns-servers 1.1.1.1,8.8.8.8 https://example.com
|
|
383
|
+
curlie --doh-url https://dns.google/resolve https://example.com
|
|
384
|
+
curlie --ipv4 https://example.com`);
|
|
385
385
|
break;
|
|
386
386
|
|
|
387
387
|
default:
|
|
388
388
|
console.log(synopsis);
|
|
389
|
-
console.log(`\nTry '
|
|
389
|
+
console.log(`\nTry 'curlie -h' for more options`);
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
process.exit(0);
|
|
@@ -575,7 +575,7 @@ export function saveCookieJar(jarPath, setCookies, hostname) {
|
|
|
575
575
|
}
|
|
576
576
|
|
|
577
577
|
let output = "# Netscape HTTP Cookie File\n";
|
|
578
|
-
output += "# This file was generated by
|
|
578
|
+
output += "# This file was generated by curlie\n\n";
|
|
579
579
|
|
|
580
580
|
for (const cookie of existing.values()) {
|
|
581
581
|
const flag = cookie.flag ? "TRUE" : "FALSE";
|