@ohos-ports/curlconverter 4.12.0-beta.0

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.
Files changed (270) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +153 -0
  3. package/dist/src/Headers.d.ts +23 -0
  4. package/dist/src/Headers.js +287 -0
  5. package/dist/src/Headers.js.map +1 -0
  6. package/dist/src/Query.d.ts +8 -0
  7. package/dist/src/Query.js +136 -0
  8. package/dist/src/Query.js.map +1 -0
  9. package/dist/src/Request.d.ts +200 -0
  10. package/dist/src/Request.js +1191 -0
  11. package/dist/src/Request.js.map +1 -0
  12. package/dist/src/Warnings.d.ts +15 -0
  13. package/dist/src/Warnings.js +111 -0
  14. package/dist/src/Warnings.js.map +1 -0
  15. package/dist/src/cli.d.ts +2 -0
  16. package/dist/src/cli.js +333 -0
  17. package/dist/src/cli.js.map +1 -0
  18. package/dist/src/curl/auth.d.ts +12 -0
  19. package/dist/src/curl/auth.js +40 -0
  20. package/dist/src/curl/auth.js.map +1 -0
  21. package/dist/src/curl/form.d.ts +28 -0
  22. package/dist/src/curl/form.js +218 -0
  23. package/dist/src/curl/form.js.map +1 -0
  24. package/dist/src/curl/opts.d.ts +2052 -0
  25. package/dist/src/curl/opts.js +1000 -0
  26. package/dist/src/curl/opts.js.map +1 -0
  27. package/dist/src/curl/url.d.ts +14 -0
  28. package/dist/src/curl/url.js +218 -0
  29. package/dist/src/curl/url.js.map +1 -0
  30. package/dist/src/generators/ansible.d.ts +5 -0
  31. package/dist/src/generators/ansible.js +282 -0
  32. package/dist/src/generators/ansible.js.map +1 -0
  33. package/dist/src/generators/c.d.ts +12 -0
  34. package/dist/src/generators/c.js +1230 -0
  35. package/dist/src/generators/c.js.map +1 -0
  36. package/dist/src/generators/cfml.d.ts +5 -0
  37. package/dist/src/generators/cfml.js +134 -0
  38. package/dist/src/generators/cfml.js.map +1 -0
  39. package/dist/src/generators/clojure.d.ts +7 -0
  40. package/dist/src/generators/clojure.js +436 -0
  41. package/dist/src/generators/clojure.js.map +1 -0
  42. package/dist/src/generators/csharp.d.ts +8 -0
  43. package/dist/src/generators/csharp.js +356 -0
  44. package/dist/src/generators/csharp.js.map +1 -0
  45. package/dist/src/generators/dart.d.ts +5 -0
  46. package/dist/src/generators/dart.js +273 -0
  47. package/dist/src/generators/dart.js.map +1 -0
  48. package/dist/src/generators/elixir.d.ts +8 -0
  49. package/dist/src/generators/elixir.js +296 -0
  50. package/dist/src/generators/elixir.js.map +1 -0
  51. package/dist/src/generators/go.d.ts +5 -0
  52. package/dist/src/generators/go.js +228 -0
  53. package/dist/src/generators/go.js.map +1 -0
  54. package/dist/src/generators/har.d.ts +7 -0
  55. package/dist/src/generators/har.js +115 -0
  56. package/dist/src/generators/har.js.map +1 -0
  57. package/dist/src/generators/http.d.ts +7 -0
  58. package/dist/src/generators/http.js +165 -0
  59. package/dist/src/generators/http.js.map +1 -0
  60. package/dist/src/generators/httpie.d.ts +5 -0
  61. package/dist/src/generators/httpie.js +446 -0
  62. package/dist/src/generators/httpie.js.map +1 -0
  63. package/dist/src/generators/java/httpurlconnection.d.ts +5 -0
  64. package/dist/src/generators/java/httpurlconnection.js +123 -0
  65. package/dist/src/generators/java/httpurlconnection.js.map +1 -0
  66. package/dist/src/generators/java/java.d.ts +8 -0
  67. package/dist/src/generators/java/java.js +247 -0
  68. package/dist/src/generators/java/java.js.map +1 -0
  69. package/dist/src/generators/java/jsoup.d.ts +5 -0
  70. package/dist/src/generators/java/jsoup.js +152 -0
  71. package/dist/src/generators/java/jsoup.js.map +1 -0
  72. package/dist/src/generators/java/okhttp.d.ts +5 -0
  73. package/dist/src/generators/java/okhttp.js +232 -0
  74. package/dist/src/generators/java/okhttp.js.map +1 -0
  75. package/dist/src/generators/javascript/axios.d.ts +5 -0
  76. package/dist/src/generators/javascript/axios.js +332 -0
  77. package/dist/src/generators/javascript/axios.js.map +1 -0
  78. package/dist/src/generators/javascript/got.d.ts +5 -0
  79. package/dist/src/generators/javascript/got.js +277 -0
  80. package/dist/src/generators/javascript/got.js.map +1 -0
  81. package/dist/src/generators/javascript/http.d.ts +8 -0
  82. package/dist/src/generators/javascript/http.js +183 -0
  83. package/dist/src/generators/javascript/http.js.map +1 -0
  84. package/dist/src/generators/javascript/javascript.d.ts +37 -0
  85. package/dist/src/generators/javascript/javascript.js +676 -0
  86. package/dist/src/generators/javascript/javascript.js.map +1 -0
  87. package/dist/src/generators/javascript/jquery.d.ts +15 -0
  88. package/dist/src/generators/javascript/jquery.js +297 -0
  89. package/dist/src/generators/javascript/jquery.js.map +1 -0
  90. package/dist/src/generators/javascript/ky.d.ts +7 -0
  91. package/dist/src/generators/javascript/ky.js +245 -0
  92. package/dist/src/generators/javascript/ky.js.map +1 -0
  93. package/dist/src/generators/javascript/request.d.ts +5 -0
  94. package/dist/src/generators/javascript/request.js +113 -0
  95. package/dist/src/generators/javascript/request.js.map +1 -0
  96. package/dist/src/generators/javascript/superagent.d.ts +10 -0
  97. package/dist/src/generators/javascript/superagent.js +301 -0
  98. package/dist/src/generators/javascript/superagent.js.map +1 -0
  99. package/dist/src/generators/javascript/xhr.d.ts +8 -0
  100. package/dist/src/generators/javascript/xhr.js +147 -0
  101. package/dist/src/generators/javascript/xhr.js.map +1 -0
  102. package/dist/src/generators/json.d.ts +45 -0
  103. package/dist/src/generators/json.js +197 -0
  104. package/dist/src/generators/json.js.map +1 -0
  105. package/dist/src/generators/julia.d.ts +8 -0
  106. package/dist/src/generators/julia.js +365 -0
  107. package/dist/src/generators/julia.js.map +1 -0
  108. package/dist/src/generators/kotlin.d.ts +8 -0
  109. package/dist/src/generators/kotlin.js +325 -0
  110. package/dist/src/generators/kotlin.js.map +1 -0
  111. package/dist/src/generators/lua.d.ts +5 -0
  112. package/dist/src/generators/lua.js +192 -0
  113. package/dist/src/generators/lua.js.map +1 -0
  114. package/dist/src/generators/matlab/common.d.ts +16 -0
  115. package/dist/src/generators/matlab/common.js +238 -0
  116. package/dist/src/generators/matlab/common.js.map +1 -0
  117. package/dist/src/generators/matlab/httpinterface.d.ts +2 -0
  118. package/dist/src/generators/matlab/httpinterface.js +211 -0
  119. package/dist/src/generators/matlab/httpinterface.js.map +1 -0
  120. package/dist/src/generators/matlab/matlab.d.ts +5 -0
  121. package/dist/src/generators/matlab/matlab.js +29 -0
  122. package/dist/src/generators/matlab/matlab.js.map +1 -0
  123. package/dist/src/generators/matlab/webservices.d.ts +2 -0
  124. package/dist/src/generators/matlab/webservices.js +191 -0
  125. package/dist/src/generators/matlab/webservices.js.map +1 -0
  126. package/dist/src/generators/objectivec.d.ts +8 -0
  127. package/dist/src/generators/objectivec.js +269 -0
  128. package/dist/src/generators/objectivec.js.map +1 -0
  129. package/dist/src/generators/ocaml.d.ts +8 -0
  130. package/dist/src/generators/ocaml.js +150 -0
  131. package/dist/src/generators/ocaml.js.map +1 -0
  132. package/dist/src/generators/perl.d.ts +9 -0
  133. package/dist/src/generators/perl.js +209 -0
  134. package/dist/src/generators/perl.js.map +1 -0
  135. package/dist/src/generators/php/guzzle.d.ts +5 -0
  136. package/dist/src/generators/php/guzzle.js +328 -0
  137. package/dist/src/generators/php/guzzle.js.map +1 -0
  138. package/dist/src/generators/php/php.d.ts +8 -0
  139. package/dist/src/generators/php/php.js +217 -0
  140. package/dist/src/generators/php/php.js.map +1 -0
  141. package/dist/src/generators/php/requests.d.ts +5 -0
  142. package/dist/src/generators/php/requests.js +89 -0
  143. package/dist/src/generators/php/requests.js.map +1 -0
  144. package/dist/src/generators/powershell.d.ts +11 -0
  145. package/dist/src/generators/powershell.js +377 -0
  146. package/dist/src/generators/powershell.js.map +1 -0
  147. package/dist/src/generators/python/http.d.ts +5 -0
  148. package/dist/src/generators/python/http.js +128 -0
  149. package/dist/src/generators/python/http.js.map +1 -0
  150. package/dist/src/generators/python/python.d.ts +22 -0
  151. package/dist/src/generators/python/python.js +1693 -0
  152. package/dist/src/generators/python/python.js.map +1 -0
  153. package/dist/src/generators/r/httr.d.ts +10 -0
  154. package/dist/src/generators/r/httr.js +298 -0
  155. package/dist/src/generators/r/httr.js.map +1 -0
  156. package/dist/src/generators/r/httr2.d.ts +5 -0
  157. package/dist/src/generators/r/httr2.js +214 -0
  158. package/dist/src/generators/r/httr2.js.map +1 -0
  159. package/dist/src/generators/ruby/httparty.d.ts +6 -0
  160. package/dist/src/generators/ruby/httparty.js +308 -0
  161. package/dist/src/generators/ruby/httparty.js.map +1 -0
  162. package/dist/src/generators/ruby/ruby.d.ts +14 -0
  163. package/dist/src/generators/ruby/ruby.js +515 -0
  164. package/dist/src/generators/ruby/ruby.js.map +1 -0
  165. package/dist/src/generators/rust.d.ts +8 -0
  166. package/dist/src/generators/rust.js +177 -0
  167. package/dist/src/generators/rust.js.map +1 -0
  168. package/dist/src/generators/swift.d.ts +8 -0
  169. package/dist/src/generators/swift.js +219 -0
  170. package/dist/src/generators/swift.js.map +1 -0
  171. package/dist/src/generators/wget.d.ts +8 -0
  172. package/dist/src/generators/wget.js +472 -0
  173. package/dist/src/generators/wget.js.map +1 -0
  174. package/dist/src/index.d.ts +53 -0
  175. package/dist/src/index.js +54 -0
  176. package/dist/src/index.js.map +1 -0
  177. package/dist/src/parse.d.ts +13 -0
  178. package/dist/src/parse.js +43 -0
  179. package/dist/src/parse.js.map +1 -0
  180. package/dist/src/shell/Parser.d.ts +4 -0
  181. package/dist/src/shell/Parser.js +6 -0
  182. package/dist/src/shell/Parser.js.map +1 -0
  183. package/dist/src/shell/Word.d.ts +48 -0
  184. package/dist/src/shell/Word.js +486 -0
  185. package/dist/src/shell/Word.js.map +1 -0
  186. package/dist/src/shell/tokenizer.d.ts +3 -0
  187. package/dist/src/shell/tokenizer.js +610 -0
  188. package/dist/src/shell/tokenizer.js.map +1 -0
  189. package/dist/src/shell/webParser.d.ts +4 -0
  190. package/dist/src/shell/webParser.js +15 -0
  191. package/dist/src/shell/webParser.js.map +1 -0
  192. package/dist/src/utils.d.ts +6 -0
  193. package/dist/src/utils.js +21 -0
  194. package/dist/src/utils.js.map +1 -0
  195. package/dist/tools/compare-requests.d.ts +2 -0
  196. package/dist/tools/compare-requests.js +448 -0
  197. package/dist/tools/compare-requests.js.map +1 -0
  198. package/dist/tools/gen-test.d.ts +2 -0
  199. package/dist/tools/gen-test.js +114 -0
  200. package/dist/tools/gen-test.js.map +1 -0
  201. package/dist/tree-sitter-bash.wasm +0 -0
  202. package/index.d.ts +3 -0
  203. package/package.json +97 -0
  204. package/src/Headers.ts +334 -0
  205. package/src/Query.ts +147 -0
  206. package/src/Request.ts +1649 -0
  207. package/src/Warnings.ts +154 -0
  208. package/src/cli.ts +561 -0
  209. package/src/curl/auth.ts +45 -0
  210. package/src/curl/form.ts +297 -0
  211. package/src/curl/opts.ts +1417 -0
  212. package/src/curl/url.ts +241 -0
  213. package/src/generators/ansible.ts +364 -0
  214. package/src/generators/c.ts +1371 -0
  215. package/src/generators/cfml.ts +155 -0
  216. package/src/generators/clojure.ts +521 -0
  217. package/src/generators/csharp.ts +383 -0
  218. package/src/generators/dart.ts +293 -0
  219. package/src/generators/elixir.ts +349 -0
  220. package/src/generators/go.ts +269 -0
  221. package/src/generators/har.ts +147 -0
  222. package/src/generators/http.ts +194 -0
  223. package/src/generators/httpie.ts +506 -0
  224. package/src/generators/java/httpurlconnection.ts +151 -0
  225. package/src/generators/java/java.ts +280 -0
  226. package/src/generators/java/jsoup.ts +172 -0
  227. package/src/generators/java/okhttp.ts +257 -0
  228. package/src/generators/javascript/axios.ts +395 -0
  229. package/src/generators/javascript/got.ts +362 -0
  230. package/src/generators/javascript/http.ts +232 -0
  231. package/src/generators/javascript/javascript.ts +825 -0
  232. package/src/generators/javascript/jquery.ts +360 -0
  233. package/src/generators/javascript/ky.ts +315 -0
  234. package/src/generators/javascript/request.ts +152 -0
  235. package/src/generators/javascript/superagent.ts +373 -0
  236. package/src/generators/javascript/xhr.ts +192 -0
  237. package/src/generators/json.ts +293 -0
  238. package/src/generators/julia.ts +398 -0
  239. package/src/generators/kotlin.ts +355 -0
  240. package/src/generators/lua.ts +209 -0
  241. package/src/generators/matlab/common.ts +281 -0
  242. package/src/generators/matlab/httpinterface.ts +284 -0
  243. package/src/generators/matlab/matlab.ts +39 -0
  244. package/src/generators/matlab/webservices.ts +263 -0
  245. package/src/generators/objectivec.ts +297 -0
  246. package/src/generators/ocaml.ts +168 -0
  247. package/src/generators/perl.ts +237 -0
  248. package/src/generators/php/guzzle.ts +368 -0
  249. package/src/generators/php/php.ts +239 -0
  250. package/src/generators/php/requests.ts +103 -0
  251. package/src/generators/powershell.ts +430 -0
  252. package/src/generators/python/http.ts +167 -0
  253. package/src/generators/python/python.ts +1934 -0
  254. package/src/generators/r/httr.ts +328 -0
  255. package/src/generators/r/httr2.ts +268 -0
  256. package/src/generators/ruby/httparty.ts +351 -0
  257. package/src/generators/ruby/ruby.ts +564 -0
  258. package/src/generators/rust.ts +243 -0
  259. package/src/generators/swift.ts +235 -0
  260. package/src/generators/wget.ts +533 -0
  261. package/src/index.ts +89 -0
  262. package/src/parse.ts +72 -0
  263. package/src/shell/Parser.ts +8 -0
  264. package/src/shell/Word.ts +531 -0
  265. package/src/shell/tokenizer.ts +736 -0
  266. package/src/shell/webParser.ts +18 -0
  267. package/src/utils.ts +25 -0
  268. package/tools/compare-requests.ts +571 -0
  269. package/tools/extract_curl_args.py +511 -0
  270. package/tools/gen-test.ts +129 -0
@@ -0,0 +1,1000 @@
1
+ import { CCError, has } from "../utils.js";
2
+ import { eq, firstShellToken } from "../shell/Word.js";
3
+ import { warnf, underlineNode } from "../Warnings.js";
4
+ import { CURLAUTH_BASIC, CURLAUTH_DIGEST, CURLAUTH_NEGOTIATE, CURLAUTH_NTLM, CURLAUTH_NTLM_WB, CURLAUTH_BEARER, CURLAUTH_AWS_SIGV4, CURLAUTH_ANY, } from "./auth.js";
5
+ // prettier-ignore
6
+ export const curlLongOpts = {
7
+ // BEGIN EXTRACTED OPTIONS
8
+ "url": { type: "string", name: "url" },
9
+ "dns-ipv4-addr": { type: "string", name: "dns-ipv4-addr" },
10
+ "dns-ipv6-addr": { type: "string", name: "dns-ipv6-addr" },
11
+ "random-file": { type: "string", name: "random-file" },
12
+ "egd-file": { type: "string", name: "egd-file" },
13
+ "oauth2-bearer": { type: "string", name: "oauth2-bearer" },
14
+ "connect-timeout": { type: "string", name: "connect-timeout" },
15
+ "doh-url": { type: "string", name: "doh-url" },
16
+ "ciphers": { type: "string", name: "ciphers" },
17
+ "dns-interface": { type: "string", name: "dns-interface" },
18
+ "disable-epsv": { type: "bool", name: "disable-epsv" },
19
+ "no-disable-epsv": { type: "bool", name: "disable-epsv", expand: false },
20
+ "disallow-username-in-url": { type: "bool", name: "disallow-username-in-url" },
21
+ "no-disallow-username-in-url": { type: "bool", name: "disallow-username-in-url", expand: false },
22
+ "epsv": { type: "bool", name: "epsv" },
23
+ "no-epsv": { type: "bool", name: "epsv", expand: false },
24
+ "dns-servers": { type: "string", name: "dns-servers" },
25
+ "trace": { type: "string", name: "trace" },
26
+ "npn": { type: "bool", name: "npn" },
27
+ "no-npn": { type: "bool", name: "npn", expand: false },
28
+ "trace-ascii": { type: "string", name: "trace-ascii" },
29
+ "alpn": { type: "bool", name: "alpn" },
30
+ "no-alpn": { type: "bool", name: "alpn", expand: false },
31
+ "limit-rate": { type: "string", name: "limit-rate" },
32
+ "rate": { type: "string", name: "rate" },
33
+ "compressed": { type: "bool", name: "compressed" },
34
+ "no-compressed": { type: "bool", name: "compressed", expand: false },
35
+ "tr-encoding": { type: "bool", name: "tr-encoding" },
36
+ "no-tr-encoding": { type: "bool", name: "tr-encoding", expand: false },
37
+ "digest": { type: "bool", name: "digest" },
38
+ "no-digest": { type: "bool", name: "digest", expand: false },
39
+ "negotiate": { type: "bool", name: "negotiate" },
40
+ "no-negotiate": { type: "bool", name: "negotiate", expand: false },
41
+ "ntlm": { type: "bool", name: "ntlm" },
42
+ "no-ntlm": { type: "bool", name: "ntlm", expand: false },
43
+ "ntlm-wb": { type: "bool", name: "ntlm-wb" },
44
+ "no-ntlm-wb": { type: "bool", name: "ntlm-wb", expand: false },
45
+ "basic": { type: "bool", name: "basic" },
46
+ "no-basic": { type: "bool", name: "basic", expand: false },
47
+ "anyauth": { type: "bool", name: "anyauth" },
48
+ "no-anyauth": { type: "bool", name: "anyauth", expand: false },
49
+ "wdebug": { type: "bool", name: "wdebug" },
50
+ "no-wdebug": { type: "bool", name: "wdebug", expand: false },
51
+ "ftp-create-dirs": { type: "bool", name: "ftp-create-dirs" },
52
+ "no-ftp-create-dirs": { type: "bool", name: "ftp-create-dirs", expand: false },
53
+ "create-dirs": { type: "bool", name: "create-dirs" },
54
+ "no-create-dirs": { type: "bool", name: "create-dirs", expand: false },
55
+ "create-file-mode": { type: "string", name: "create-file-mode" },
56
+ "max-redirs": { type: "string", name: "max-redirs" },
57
+ "proxy-ntlm": { type: "bool", name: "proxy-ntlm" },
58
+ "no-proxy-ntlm": { type: "bool", name: "proxy-ntlm", expand: false },
59
+ "crlf": { type: "bool", name: "crlf" },
60
+ "no-crlf": { type: "bool", name: "crlf", expand: false },
61
+ "stderr": { type: "string", name: "stderr" },
62
+ "aws-sigv4": { type: "string", name: "aws-sigv4" },
63
+ "interface": { type: "string", name: "interface" },
64
+ "krb": { type: "string", name: "krb" },
65
+ "krb4": { type: "string", name: "krb" },
66
+ "haproxy-protocol": { type: "bool", name: "haproxy-protocol" },
67
+ "no-haproxy-protocol": { type: "bool", name: "haproxy-protocol", expand: false },
68
+ "haproxy-clientip": { type: "string", name: "haproxy-clientip" },
69
+ "max-filesize": { type: "string", name: "max-filesize" },
70
+ "disable-eprt": { type: "bool", name: "disable-eprt" },
71
+ "no-disable-eprt": { type: "bool", name: "disable-eprt", expand: false },
72
+ "eprt": { type: "bool", name: "eprt" },
73
+ "no-eprt": { type: "bool", name: "eprt", expand: false },
74
+ "xattr": { type: "bool", name: "xattr" },
75
+ "no-xattr": { type: "bool", name: "xattr", expand: false },
76
+ "ftp-ssl": { type: "bool", name: "ssl" },
77
+ "no-ftp-ssl": { type: "bool", name: "ssl", expand: false },
78
+ "ssl": { type: "bool", name: "ssl" },
79
+ "no-ssl": { type: "bool", name: "ssl", expand: false },
80
+ "ftp-pasv": { type: "bool", name: "ftp-pasv" },
81
+ "no-ftp-pasv": { type: "bool", name: "ftp-pasv", expand: false },
82
+ "socks5": { type: "string", name: "socks5" },
83
+ "tcp-nodelay": { type: "bool", name: "tcp-nodelay" },
84
+ "no-tcp-nodelay": { type: "bool", name: "tcp-nodelay", expand: false },
85
+ "proxy-digest": { type: "bool", name: "proxy-digest" },
86
+ "no-proxy-digest": { type: "bool", name: "proxy-digest", expand: false },
87
+ "proxy-basic": { type: "bool", name: "proxy-basic" },
88
+ "no-proxy-basic": { type: "bool", name: "proxy-basic", expand: false },
89
+ "retry": { type: "string", name: "retry" },
90
+ "retry-connrefused": { type: "bool", name: "retry-connrefused" },
91
+ "no-retry-connrefused": { type: "bool", name: "retry-connrefused", expand: false },
92
+ "retry-delay": { type: "string", name: "retry-delay" },
93
+ "retry-max-time": { type: "string", name: "retry-max-time" },
94
+ "proxy-negotiate": { type: "bool", name: "proxy-negotiate" },
95
+ "no-proxy-negotiate": { type: "bool", name: "proxy-negotiate", expand: false },
96
+ "form-escape": { type: "bool", name: "form-escape" },
97
+ "no-form-escape": { type: "bool", name: "form-escape", expand: false },
98
+ "ftp-account": { type: "string", name: "ftp-account" },
99
+ "proxy-anyauth": { type: "bool", name: "proxy-anyauth" },
100
+ "no-proxy-anyauth": { type: "bool", name: "proxy-anyauth", expand: false },
101
+ "trace-time": { type: "bool", name: "trace-time" },
102
+ "no-trace-time": { type: "bool", name: "trace-time", expand: false },
103
+ "ignore-content-length": { type: "bool", name: "ignore-content-length" },
104
+ "no-ignore-content-length": { type: "bool", name: "ignore-content-length", expand: false },
105
+ "ftp-skip-pasv-ip": { type: "bool", name: "ftp-skip-pasv-ip" },
106
+ "no-ftp-skip-pasv-ip": { type: "bool", name: "ftp-skip-pasv-ip", expand: false },
107
+ "ftp-method": { type: "string", name: "ftp-method" },
108
+ "local-port": { type: "string", name: "local-port" },
109
+ "socks4": { type: "string", name: "socks4" },
110
+ "socks4a": { type: "string", name: "socks4a" },
111
+ "ftp-alternative-to-user": { type: "string", name: "ftp-alternative-to-user" },
112
+ "ftp-ssl-reqd": { type: "bool", name: "ssl-reqd" },
113
+ "no-ftp-ssl-reqd": { type: "bool", name: "ssl-reqd", expand: false },
114
+ "ssl-reqd": { type: "bool", name: "ssl-reqd" },
115
+ "no-ssl-reqd": { type: "bool", name: "ssl-reqd", expand: false },
116
+ "sessionid": { type: "bool", name: "sessionid" },
117
+ "no-sessionid": { type: "bool", name: "sessionid", expand: false },
118
+ "ftp-ssl-control": { type: "bool", name: "ftp-ssl-control" },
119
+ "no-ftp-ssl-control": { type: "bool", name: "ftp-ssl-control", expand: false },
120
+ "ftp-ssl-ccc": { type: "bool", name: "ftp-ssl-ccc" },
121
+ "no-ftp-ssl-ccc": { type: "bool", name: "ftp-ssl-ccc", expand: false },
122
+ "ftp-ssl-ccc-mode": { type: "string", name: "ftp-ssl-ccc-mode" },
123
+ "libcurl": { type: "string", name: "libcurl" },
124
+ "raw": { type: "bool", name: "raw" },
125
+ "no-raw": { type: "bool", name: "raw", expand: false },
126
+ "post301": { type: "bool", name: "post301" },
127
+ "no-post301": { type: "bool", name: "post301", expand: false },
128
+ "keepalive": { type: "bool", name: "keepalive" },
129
+ "no-keepalive": { type: "bool", name: "keepalive", expand: false },
130
+ "socks5-hostname": { type: "string", name: "socks5-hostname" },
131
+ "keepalive-time": { type: "string", name: "keepalive-time" },
132
+ "post302": { type: "bool", name: "post302" },
133
+ "no-post302": { type: "bool", name: "post302", expand: false },
134
+ "noproxy": { type: "string", name: "noproxy" },
135
+ "socks5-gssapi-nec": { type: "bool", name: "socks5-gssapi-nec" },
136
+ "no-socks5-gssapi-nec": { type: "bool", name: "socks5-gssapi-nec", expand: false },
137
+ "proxy1.0": { type: "string", name: "proxy1.0" },
138
+ "tftp-blksize": { type: "string", name: "tftp-blksize" },
139
+ "mail-from": { type: "string", name: "mail-from" },
140
+ "mail-rcpt": { type: "string", name: "mail-rcpt" },
141
+ "ftp-pret": { type: "bool", name: "ftp-pret" },
142
+ "no-ftp-pret": { type: "bool", name: "ftp-pret", expand: false },
143
+ "proto": { type: "string", name: "proto" },
144
+ "proto-redir": { type: "string", name: "proto-redir" },
145
+ "resolve": { type: "string", name: "resolve" },
146
+ "delegation": { type: "string", name: "delegation" },
147
+ "mail-auth": { type: "string", name: "mail-auth" },
148
+ "post303": { type: "bool", name: "post303" },
149
+ "no-post303": { type: "bool", name: "post303", expand: false },
150
+ "metalink": { type: "bool", name: "metalink" },
151
+ "no-metalink": { type: "bool", name: "metalink", expand: false },
152
+ "sasl-authzid": { type: "string", name: "sasl-authzid" },
153
+ "sasl-ir": { type: "bool", name: "sasl-ir" },
154
+ "no-sasl-ir": { type: "bool", name: "sasl-ir", expand: false },
155
+ "test-event": { type: "bool", name: "test-event" },
156
+ "no-test-event": { type: "bool", name: "test-event", expand: false },
157
+ "unix-socket": { type: "string", name: "unix-socket" },
158
+ "path-as-is": { type: "bool", name: "path-as-is" },
159
+ "no-path-as-is": { type: "bool", name: "path-as-is", expand: false },
160
+ "socks5-gssapi-service": { type: "string", name: "proxy-service-name" },
161
+ "proxy-service-name": { type: "string", name: "proxy-service-name" },
162
+ "service-name": { type: "string", name: "service-name" },
163
+ "proto-default": { type: "string", name: "proto-default" },
164
+ "expect100-timeout": { type: "string", name: "expect100-timeout" },
165
+ "tftp-no-options": { type: "bool", name: "tftp-no-options" },
166
+ "no-tftp-no-options": { type: "bool", name: "tftp-no-options", expand: false },
167
+ "connect-to": { type: "string", name: "connect-to" },
168
+ "abstract-unix-socket": { type: "string", name: "abstract-unix-socket" },
169
+ "tls-max": { type: "string", name: "tls-max" },
170
+ "suppress-connect-headers": { type: "bool", name: "suppress-connect-headers" },
171
+ "no-suppress-connect-headers": { type: "bool", name: "suppress-connect-headers", expand: false },
172
+ "compressed-ssh": { type: "bool", name: "compressed-ssh" },
173
+ "no-compressed-ssh": { type: "bool", name: "compressed-ssh", expand: false },
174
+ "happy-eyeballs-timeout-ms": { type: "string", name: "happy-eyeballs-timeout-ms" },
175
+ "retry-all-errors": { type: "bool", name: "retry-all-errors" },
176
+ "no-retry-all-errors": { type: "bool", name: "retry-all-errors", expand: false },
177
+ "trace-ids": { type: "bool", name: "trace-ids" },
178
+ "no-trace-ids": { type: "bool", name: "trace-ids", expand: false },
179
+ "http1.0": { type: "bool", name: "http1.0" },
180
+ "http1.1": { type: "bool", name: "http1.1" },
181
+ "http2": { type: "bool", name: "http2" },
182
+ "http2-prior-knowledge": { type: "bool", name: "http2-prior-knowledge" },
183
+ "http3": { type: "bool", name: "http3" },
184
+ "http3-only": { type: "bool", name: "http3-only" },
185
+ "http0.9": { type: "bool", name: "http0.9" },
186
+ "no-http0.9": { type: "bool", name: "http0.9", expand: false },
187
+ "proxy-http2": { type: "bool", name: "proxy-http2" },
188
+ "no-proxy-http2": { type: "bool", name: "proxy-http2", expand: false },
189
+ "tlsv1": { type: "bool", name: "tlsv1" },
190
+ "tlsv1.0": { type: "bool", name: "tlsv1.0" },
191
+ "tlsv1.1": { type: "bool", name: "tlsv1.1" },
192
+ "tlsv1.2": { type: "bool", name: "tlsv1.2" },
193
+ "tlsv1.3": { type: "bool", name: "tlsv1.3" },
194
+ "tls13-ciphers": { type: "string", name: "tls13-ciphers" },
195
+ "proxy-tls13-ciphers": { type: "string", name: "proxy-tls13-ciphers" },
196
+ "sslv2": { type: "bool", name: "sslv2" },
197
+ "sslv3": { type: "bool", name: "sslv3" },
198
+ "ipv4": { type: "bool", name: "ipv4" },
199
+ "ipv6": { type: "bool", name: "ipv6" },
200
+ "append": { type: "bool", name: "append" },
201
+ "no-append": { type: "bool", name: "append", expand: false },
202
+ "user-agent": { type: "string", name: "user-agent" },
203
+ "cookie": { type: "string", name: "cookie" },
204
+ "alt-svc": { type: "string", name: "alt-svc" },
205
+ "hsts": { type: "string", name: "hsts" },
206
+ "use-ascii": { type: "bool", name: "use-ascii" },
207
+ "no-use-ascii": { type: "bool", name: "use-ascii", expand: false },
208
+ "cookie-jar": { type: "string", name: "cookie-jar" },
209
+ "continue-at": { type: "string", name: "continue-at" },
210
+ "data": { type: "string", name: "data" },
211
+ "data-raw": { type: "string", name: "data-raw" },
212
+ "data-ascii": { type: "string", name: "data-ascii" },
213
+ "data-binary": { type: "string", name: "data-binary" },
214
+ "data-urlencode": { type: "string", name: "data-urlencode" },
215
+ "json": { type: "string", name: "json" },
216
+ "url-query": { type: "string", name: "url-query" },
217
+ "dump-header": { type: "string", name: "dump-header" },
218
+ "referer": { type: "string", name: "referer" },
219
+ "cert": { type: "string", name: "cert" },
220
+ "cacert": { type: "string", name: "cacert" },
221
+ "cert-type": { type: "string", name: "cert-type" },
222
+ "key": { type: "string", name: "key" },
223
+ "key-type": { type: "string", name: "key-type" },
224
+ "pass": { type: "string", name: "pass" },
225
+ "engine": { type: "string", name: "engine" },
226
+ "ca-native": { type: "bool", name: "ca-native" },
227
+ "no-ca-native": { type: "bool", name: "ca-native", expand: false },
228
+ "proxy-ca-native": { type: "bool", name: "proxy-ca-native" },
229
+ "no-proxy-ca-native": { type: "bool", name: "proxy-ca-native", expand: false },
230
+ "capath": { type: "string", name: "capath" },
231
+ "pubkey": { type: "string", name: "pubkey" },
232
+ "hostpubmd5": { type: "string", name: "hostpubmd5" },
233
+ "hostpubsha256": { type: "string", name: "hostpubsha256" },
234
+ "crlfile": { type: "string", name: "crlfile" },
235
+ "tlsuser": { type: "string", name: "tlsuser" },
236
+ "tlspassword": { type: "string", name: "tlspassword" },
237
+ "tlsauthtype": { type: "string", name: "tlsauthtype" },
238
+ "ssl-allow-beast": { type: "bool", name: "ssl-allow-beast" },
239
+ "no-ssl-allow-beast": { type: "bool", name: "ssl-allow-beast", expand: false },
240
+ "ssl-auto-client-cert": { type: "bool", name: "ssl-auto-client-cert" },
241
+ "no-ssl-auto-client-cert": { type: "bool", name: "ssl-auto-client-cert", expand: false },
242
+ "proxy-ssl-auto-client-cert": { type: "bool", name: "proxy-ssl-auto-client-cert" },
243
+ "no-proxy-ssl-auto-client-cert": { type: "bool", name: "proxy-ssl-auto-client-cert", expand: false },
244
+ "pinnedpubkey": { type: "string", name: "pinnedpubkey" },
245
+ "proxy-pinnedpubkey": { type: "string", name: "proxy-pinnedpubkey" },
246
+ "cert-status": { type: "bool", name: "cert-status" },
247
+ "no-cert-status": { type: "bool", name: "cert-status", expand: false },
248
+ "doh-cert-status": { type: "bool", name: "doh-cert-status" },
249
+ "no-doh-cert-status": { type: "bool", name: "doh-cert-status", expand: false },
250
+ "false-start": { type: "bool", name: "false-start" },
251
+ "no-false-start": { type: "bool", name: "false-start", expand: false },
252
+ "ssl-no-revoke": { type: "bool", name: "ssl-no-revoke" },
253
+ "no-ssl-no-revoke": { type: "bool", name: "ssl-no-revoke", expand: false },
254
+ "ssl-revoke-best-effort": { type: "bool", name: "ssl-revoke-best-effort" },
255
+ "no-ssl-revoke-best-effort": { type: "bool", name: "ssl-revoke-best-effort", expand: false },
256
+ "tcp-fastopen": { type: "bool", name: "tcp-fastopen" },
257
+ "no-tcp-fastopen": { type: "bool", name: "tcp-fastopen", expand: false },
258
+ "proxy-tlsuser": { type: "string", name: "proxy-tlsuser" },
259
+ "proxy-tlspassword": { type: "string", name: "proxy-tlspassword" },
260
+ "proxy-tlsauthtype": { type: "string", name: "proxy-tlsauthtype" },
261
+ "proxy-cert": { type: "string", name: "proxy-cert" },
262
+ "proxy-cert-type": { type: "string", name: "proxy-cert-type" },
263
+ "proxy-key": { type: "string", name: "proxy-key" },
264
+ "proxy-key-type": { type: "string", name: "proxy-key-type" },
265
+ "proxy-pass": { type: "string", name: "proxy-pass" },
266
+ "proxy-ciphers": { type: "string", name: "proxy-ciphers" },
267
+ "proxy-crlfile": { type: "string", name: "proxy-crlfile" },
268
+ "proxy-ssl-allow-beast": { type: "bool", name: "proxy-ssl-allow-beast" },
269
+ "no-proxy-ssl-allow-beast": { type: "bool", name: "proxy-ssl-allow-beast", expand: false },
270
+ "login-options": { type: "string", name: "login-options" },
271
+ "proxy-cacert": { type: "string", name: "proxy-cacert" },
272
+ "proxy-capath": { type: "string", name: "proxy-capath" },
273
+ "proxy-insecure": { type: "bool", name: "proxy-insecure" },
274
+ "no-proxy-insecure": { type: "bool", name: "proxy-insecure", expand: false },
275
+ "proxy-tlsv1": { type: "bool", name: "proxy-tlsv1" },
276
+ "socks5-basic": { type: "bool", name: "socks5-basic" },
277
+ "no-socks5-basic": { type: "bool", name: "socks5-basic", expand: false },
278
+ "socks5-gssapi": { type: "bool", name: "socks5-gssapi" },
279
+ "no-socks5-gssapi": { type: "bool", name: "socks5-gssapi", expand: false },
280
+ "etag-save": { type: "string", name: "etag-save" },
281
+ "etag-compare": { type: "string", name: "etag-compare" },
282
+ "curves": { type: "string", name: "curves" },
283
+ "fail": { type: "bool", name: "fail" },
284
+ "no-fail": { type: "bool", name: "fail", expand: false },
285
+ "fail-early": { type: "bool", name: "fail-early" },
286
+ "no-fail-early": { type: "bool", name: "fail-early", expand: false },
287
+ "styled-output": { type: "bool", name: "styled-output" },
288
+ "no-styled-output": { type: "bool", name: "styled-output", expand: false },
289
+ "mail-rcpt-allowfails": { type: "bool", name: "mail-rcpt-allowfails" },
290
+ "no-mail-rcpt-allowfails": { type: "bool", name: "mail-rcpt-allowfails", expand: false },
291
+ "fail-with-body": { type: "bool", name: "fail-with-body" },
292
+ "no-fail-with-body": { type: "bool", name: "fail-with-body", expand: false },
293
+ "remove-on-error": { type: "bool", name: "remove-on-error" },
294
+ "no-remove-on-error": { type: "bool", name: "remove-on-error", expand: false },
295
+ "form": { type: "string", name: "form" },
296
+ "form-string": { type: "string", name: "form-string" },
297
+ "globoff": { type: "bool", name: "globoff" },
298
+ "no-globoff": { type: "bool", name: "globoff", expand: false },
299
+ "get": { type: "bool", name: "get" },
300
+ "no-get": { type: "bool", name: "get", expand: false },
301
+ "request-target": { type: "string", name: "request-target" },
302
+ "help": { type: "bool", name: "help" },
303
+ "no-help": { type: "bool", name: "help", expand: false },
304
+ "header": { type: "string", name: "header" },
305
+ "proxy-header": { type: "string", name: "proxy-header" },
306
+ "include": { type: "bool", name: "include" },
307
+ "no-include": { type: "bool", name: "include", expand: false },
308
+ "head": { type: "bool", name: "head" },
309
+ "no-head": { type: "bool", name: "head", expand: false },
310
+ "junk-session-cookies": { type: "bool", name: "junk-session-cookies" },
311
+ "no-junk-session-cookies": { type: "bool", name: "junk-session-cookies", expand: false },
312
+ "remote-header-name": { type: "bool", name: "remote-header-name" },
313
+ "no-remote-header-name": { type: "bool", name: "remote-header-name", expand: false },
314
+ "insecure": { type: "bool", name: "insecure" },
315
+ "no-insecure": { type: "bool", name: "insecure", expand: false },
316
+ "doh-insecure": { type: "bool", name: "doh-insecure" },
317
+ "no-doh-insecure": { type: "bool", name: "doh-insecure", expand: false },
318
+ "config": { type: "string", name: "config" },
319
+ "list-only": { type: "bool", name: "list-only" },
320
+ "no-list-only": { type: "bool", name: "list-only", expand: false },
321
+ "location": { type: "bool", name: "location" },
322
+ "no-location": { type: "bool", name: "location", expand: false },
323
+ "location-trusted": { type: "bool", name: "location-trusted" },
324
+ "no-location-trusted": { type: "bool", name: "location-trusted", expand: false },
325
+ "max-time": { type: "string", name: "max-time" },
326
+ "manual": { type: "bool", name: "manual" },
327
+ "no-manual": { type: "bool", name: "manual", expand: false },
328
+ "netrc": { type: "bool", name: "netrc" },
329
+ "no-netrc": { type: "bool", name: "netrc", expand: false },
330
+ "netrc-optional": { type: "bool", name: "netrc-optional" },
331
+ "no-netrc-optional": { type: "bool", name: "netrc-optional", expand: false },
332
+ "netrc-file": { type: "string", name: "netrc-file" },
333
+ "buffer": { type: "bool", name: "buffer" },
334
+ "no-buffer": { type: "bool", name: "buffer", expand: false },
335
+ "output": { type: "string", name: "output" },
336
+ "remote-name": { type: "bool", name: "remote-name" },
337
+ "no-remote-name": { type: "bool", name: "remote-name", expand: false },
338
+ "remote-name-all": { type: "bool", name: "remote-name-all" },
339
+ "no-remote-name-all": { type: "bool", name: "remote-name-all", expand: false },
340
+ "output-dir": { type: "string", name: "output-dir" },
341
+ "clobber": { type: "bool", name: "clobber" },
342
+ "no-clobber": { type: "bool", name: "clobber", expand: false },
343
+ "proxytunnel": { type: "bool", name: "proxytunnel" },
344
+ "no-proxytunnel": { type: "bool", name: "proxytunnel", expand: false },
345
+ "ftp-port": { type: "string", name: "ftp-port" },
346
+ "disable": { type: "bool", name: "disable" },
347
+ "no-disable": { type: "bool", name: "disable", expand: false },
348
+ "quote": { type: "string", name: "quote" },
349
+ "range": { type: "string", name: "range" },
350
+ "remote-time": { type: "bool", name: "remote-time" },
351
+ "no-remote-time": { type: "bool", name: "remote-time", expand: false },
352
+ "silent": { type: "bool", name: "silent" },
353
+ "no-silent": { type: "bool", name: "silent", expand: false },
354
+ "show-error": { type: "bool", name: "show-error" },
355
+ "no-show-error": { type: "bool", name: "show-error", expand: false },
356
+ "telnet-option": { type: "string", name: "telnet-option" },
357
+ "upload-file": { type: "string", name: "upload-file" },
358
+ "user": { type: "string", name: "user" },
359
+ "proxy-user": { type: "string", name: "proxy-user" },
360
+ "verbose": { type: "bool", name: "verbose" },
361
+ "no-verbose": { type: "bool", name: "verbose", expand: false },
362
+ "version": { type: "bool", name: "version" },
363
+ "no-version": { type: "bool", name: "version", expand: false },
364
+ "write-out": { type: "string", name: "write-out" },
365
+ "proxy": { type: "string", name: "proxy" },
366
+ "preproxy": { type: "string", name: "preproxy" },
367
+ "request": { type: "string", name: "request" },
368
+ "speed-limit": { type: "string", name: "speed-limit" },
369
+ "speed-time": { type: "string", name: "speed-time" },
370
+ "time-cond": { type: "string", name: "time-cond" },
371
+ "parallel": { type: "bool", name: "parallel" },
372
+ "no-parallel": { type: "bool", name: "parallel", expand: false },
373
+ "parallel-max": { type: "string", name: "parallel-max" },
374
+ "parallel-immediate": { type: "bool", name: "parallel-immediate" },
375
+ "no-parallel-immediate": { type: "bool", name: "parallel-immediate", expand: false },
376
+ "progress-bar": { type: "bool", name: "progress-bar" },
377
+ "no-progress-bar": { type: "bool", name: "progress-bar", expand: false },
378
+ "progress-meter": { type: "bool", name: "progress-meter" },
379
+ "no-progress-meter": { type: "bool", name: "progress-meter", expand: false },
380
+ "next": { type: "bool", name: "next" },
381
+ // END EXTRACTED OPTIONS
382
+ // These are options that curl used to have.
383
+ // Those that don't conflict with the current options are supported by curlconverter.
384
+ // TODO: curl's --long-options can be shortened.
385
+ // For example if curl used to only have a single option, "--blah" then
386
+ // "--bla" "--bl" and "--b" all used to be valid options as well. If later
387
+ // "--blaz" was added, suddenly those 3 shortened options are removed (because
388
+ // they are now ambiguous).
389
+ // https://github.com/curlconverter/curlconverter/pull/280#issuecomment-931241328
390
+ port: { type: "string", name: "port", removed: "7.3" },
391
+ // These are now shoretened forms of --upload-file and --continue-at
392
+ //upload: { type: "bool", name: "upload", removed: "7.7" },
393
+ //continue: { type: "bool", name: "continue", removed: "7.9" },
394
+ "ftp-ascii": { type: "bool", name: "use-ascii", removed: "7.10.7" },
395
+ "3p-url": { type: "string", name: "3p-url", removed: "7.16.0" },
396
+ "3p-user": { type: "string", name: "3p-user", removed: "7.16.0" },
397
+ "3p-quote": { type: "string", name: "3p-quote", removed: "7.16.0" },
398
+ "http2.0": { type: "bool", name: "http2", removed: "7.36.0" },
399
+ "no-http2.0": { type: "bool", name: "http2", removed: "7.36.0" },
400
+ "telnet-options": { type: "string", name: "telnet-option", removed: "7.49.0" },
401
+ "http-request": { type: "string", name: "request", removed: "7.49.0" },
402
+ // --socks is now an ambiguous shortening of --socks4, --socks5 and a bunch more
403
+ //socks: { type: "string", name: "socks5", removed: "7.49.0" },
404
+ "capath ": { type: "string", name: "capath", removed: "7.49.0" }, // trailing space
405
+ ftpport: { type: "string", name: "ftp-port", removed: "7.49.0" },
406
+ environment: { type: "bool", name: "environment", removed: "7.54.1" },
407
+ // These never had any effect
408
+ "no-tlsv1": { type: "bool", name: "tlsv1", removed: "7.54.1" },
409
+ "no-tlsv1.2": { type: "bool", name: "tlsv1.2", removed: "7.54.1" },
410
+ "no-http2-prior-knowledge": { type: "bool", name: "http2-prior-knowledge", removed: "7.54.1" },
411
+ "no-ipv6": { type: "bool", name: "ipv6", removed: "7.54.1" },
412
+ "no-ipv4": { type: "bool", name: "ipv4", removed: "7.54.1" },
413
+ "no-sslv2": { type: "bool", name: "sslv2", removed: "7.54.1" },
414
+ "no-tlsv1.0": { type: "bool", name: "tlsv1.0", removed: "7.54.1" },
415
+ "no-tlsv1.1": { type: "bool", name: "tlsv1.1", removed: "7.54.1" },
416
+ "no-sslv3": { type: "bool", name: "sslv3", removed: "7.54.1" },
417
+ "no-http1.0": { type: "bool", name: "http1.0", removed: "7.54.1" },
418
+ "no-next": { type: "bool", name: "next", removed: "7.54.1" },
419
+ "no-tlsv1.3": { type: "bool", name: "tlsv1.3", removed: "7.54.1" },
420
+ "no-environment": { type: "bool", name: "environment", removed: "7.54.1" },
421
+ "no-http1.1": { type: "bool", name: "http1.1", removed: "7.54.1" },
422
+ "no-proxy-tlsv1": { type: "bool", name: "proxy-tlsv1", removed: "7.54.1" },
423
+ "no-http2": { type: "bool", name: "http2", removed: "7.54.1" },
424
+ };
425
+ // curl lets you not type the full argument as long as it's unambiguous.
426
+ // So --sil instead of --silent is okay, --s is not.
427
+ export const curlLongOptsShortened = {};
428
+ for (const [opt, val] of Object.entries(curlLongOpts)) {
429
+ const expand = "expand" in val ? val.expand : true;
430
+ const removed = "removed" in val ? val.removed : false;
431
+ if (expand && !removed) {
432
+ for (let i = 1; i < opt.length; i++) {
433
+ const shortenedOpt = opt.slice(0, i);
434
+ if (!Object.prototype.hasOwnProperty.call(curlLongOptsShortened, shortenedOpt)) {
435
+ if (!Object.prototype.hasOwnProperty.call(curlLongOpts, shortenedOpt)) {
436
+ curlLongOptsShortened[shortenedOpt] = val;
437
+ }
438
+ }
439
+ else {
440
+ // If more than one option shortens to this, it's ambiguous
441
+ curlLongOptsShortened[shortenedOpt] = null;
442
+ }
443
+ }
444
+ }
445
+ }
446
+ // Arguments which are supported by all generators, because they're
447
+ // easy to implement or because they're handled by upstream code and
448
+ // affect something that's easy to implement.
449
+ export const COMMON_SUPPORTED_ARGS = [
450
+ "url",
451
+ "proto-default",
452
+ // Controls whether or not backslash-escaped [] {} will have the backslash removed.
453
+ "globoff",
454
+ // curl will exit if it finds auth credentials in the URL with this option,
455
+ // we remove it from the URL and emit a warning instead.
456
+ "disallow-username-in-url",
457
+ // Method
458
+ "request",
459
+ "get",
460
+ "head",
461
+ "no-head",
462
+ // Headers
463
+ "header", // TODO: can be a file
464
+ "user-agent",
465
+ "referer",
466
+ "range",
467
+ "time-cond",
468
+ "cookie", // TODO: can be a file
469
+ "oauth2-bearer",
470
+ // Basic Auth
471
+ "user",
472
+ "basic",
473
+ "no-basic",
474
+ // Data
475
+ "data",
476
+ "data-raw",
477
+ "data-ascii",
478
+ "data-binary",
479
+ "data-urlencode",
480
+ "json",
481
+ "url-query",
482
+ // TODO: --compressed is already the default for some runtimes, in
483
+ // which case we might have to only warn that --no-compressed isn't supported.
484
+ ];
485
+ export function toBoolean(opt) {
486
+ if (opt.startsWith("no-disable-")) {
487
+ return true;
488
+ }
489
+ if (opt.startsWith("disable-") || opt.startsWith("no-")) {
490
+ return false;
491
+ }
492
+ return true;
493
+ }
494
+ // prettier-ignore
495
+ export const curlShortOpts = {
496
+ // BEGIN EXTRACTED SHORT OPTIONS
497
+ "0": "http1.0",
498
+ "1": "tlsv1",
499
+ "2": "sslv2",
500
+ "3": "sslv3",
501
+ "4": "ipv4",
502
+ "6": "ipv6",
503
+ "a": "append",
504
+ "A": "user-agent",
505
+ "b": "cookie",
506
+ "B": "use-ascii",
507
+ "c": "cookie-jar",
508
+ "C": "continue-at",
509
+ "d": "data",
510
+ "D": "dump-header",
511
+ "e": "referer",
512
+ "E": "cert",
513
+ "f": "fail",
514
+ "F": "form",
515
+ "g": "globoff",
516
+ "G": "get",
517
+ "h": "help",
518
+ "H": "header",
519
+ "i": "include",
520
+ "I": "head",
521
+ "j": "junk-session-cookies",
522
+ "J": "remote-header-name",
523
+ "k": "insecure",
524
+ "K": "config",
525
+ "l": "list-only",
526
+ "L": "location",
527
+ "m": "max-time",
528
+ "M": "manual",
529
+ "n": "netrc",
530
+ "N": "no-buffer",
531
+ "o": "output",
532
+ "O": "remote-name",
533
+ "p": "proxytunnel",
534
+ "P": "ftp-port",
535
+ "q": "disable",
536
+ "Q": "quote",
537
+ "r": "range",
538
+ "R": "remote-time",
539
+ "s": "silent",
540
+ "S": "show-error",
541
+ "t": "telnet-option",
542
+ "T": "upload-file",
543
+ "u": "user",
544
+ "U": "proxy-user",
545
+ "v": "verbose",
546
+ "V": "version",
547
+ "w": "write-out",
548
+ "x": "proxy",
549
+ "X": "request",
550
+ "Y": "speed-limit",
551
+ "y": "speed-time",
552
+ "z": "time-cond",
553
+ "Z": "parallel",
554
+ "#": "progress-bar",
555
+ ":": "next",
556
+ // END EXTRACTED SHORT OPTIONS
557
+ };
558
+ export const changedShortOpts = {
559
+ p: "used to be short for --port <port> (a since-deleted flag) until curl 7.3",
560
+ // TODO: some of these might be renamed options
561
+ t: "used to be short for --upload (a since-deleted boolean flag) until curl 7.7",
562
+ c: "used to be short for --continue (a since-deleted boolean flag) until curl 7.9",
563
+ // TODO: did -@ actually work?
564
+ "@": "used to be short for --create-dirs until curl 7.10.7",
565
+ Z: "used to be short for --max-redirs <num> until curl 7.10.7",
566
+ 9: "used to be short for --crlf until curl 7.10.8",
567
+ 8: "used to be short for --stderr <file> until curl 7.10.8",
568
+ 7: "used to be short for --interface <name> until curl 7.10.8",
569
+ 6: "used to be short for --krb <level> (which itself used to be --krb4 <level>) until curl 7.10.8",
570
+ // TODO: did these short options ever actually work?
571
+ 5: "used to be another way to specify the url until curl 7.10.8",
572
+ "*": "used to be another way to specify the url until curl 7.49.0",
573
+ "~": "used to be short for --xattr until curl 7.49.0",
574
+ };
575
+ // type Satisfies<T, U extends T> = void;
576
+ // type AssertSubsetKeys = Satisfies<
577
+ // keyof typeof curlLongOpts | "authtype" | "proxyauthtype",
578
+ // keyof OperationConfig
579
+ // >;
580
+ // These options can be specified more than once, they
581
+ // are always returned as a list.
582
+ // For all other options, if you specify it more than once
583
+ // curl will use the last one.
584
+ const canBeList = new Set([
585
+ "connect-to",
586
+ "cookie",
587
+ "data",
588
+ "form",
589
+ "header",
590
+ "hsts",
591
+ "mail-rcpt",
592
+ "output",
593
+ "proxy-header",
594
+ "quote",
595
+ "resolve",
596
+ "telnet-option",
597
+ "upload-file",
598
+ "url-query",
599
+ "url",
600
+ ]);
601
+ function checkSupported(global_, lookup, longArg, supportedOpts) {
602
+ if (supportedOpts && !supportedOpts.has(longArg.name)) {
603
+ // TODO: better message. include generator name?
604
+ warnf(global_, [
605
+ longArg.name,
606
+ lookup +
607
+ " is not a supported option" +
608
+ (longArg.removed ? ", it was removed in curl " + longArg.removed : ""),
609
+ ]);
610
+ }
611
+ }
612
+ export function pushProp(obj, prop, value) {
613
+ if (!Object.prototype.hasOwnProperty.call(obj, prop)) {
614
+ obj[prop] = [];
615
+ }
616
+ obj[prop].push(value);
617
+ return obj;
618
+ }
619
+ function pushArgValue(global_, config, argName, value) {
620
+ // Note: cli.ts assumes that the property names on OperationConfig
621
+ // are the same as the passed in argument in an error message, so
622
+ // if you do something like
623
+ // echo curl example.com | curlconverter - --data-raw foo
624
+ // The error message will say
625
+ // "if you pass --stdin or -, you can't also pass --data"
626
+ // instead of "--data-raw".
627
+ switch (argName) {
628
+ case "data":
629
+ case "data-ascii":
630
+ return pushProp(config, "data", ["data", value]);
631
+ case "data-binary":
632
+ return pushProp(config, "data", [
633
+ // Unless it's a file, --data-binary works the same as --data
634
+ value.startsWith("@") ? "binary" : "data",
635
+ value,
636
+ ]);
637
+ case "data-raw":
638
+ return pushProp(config, "data", [
639
+ // Unless it's a file, --data-raw works the same as --data
640
+ value.startsWith("@") ? "raw" : "data",
641
+ value,
642
+ ]);
643
+ case "data-urlencode":
644
+ return pushProp(config, "data", ["urlencode", value]);
645
+ case "json":
646
+ config.json = true;
647
+ return pushProp(config, "data", ["json", value]);
648
+ case "url-query":
649
+ if (value.startsWith("+")) {
650
+ return pushProp(config, "url-query", ["raw", value.slice(1)]);
651
+ }
652
+ return pushProp(config, "url-query", ["urlencode", value]);
653
+ case "form":
654
+ return pushProp(config, "form", { value, type: "form" });
655
+ case "form-string":
656
+ return pushProp(config, "form", { value, type: "string" });
657
+ case "aws-sigv4":
658
+ config.authtype |= CURLAUTH_AWS_SIGV4;
659
+ break;
660
+ case "oauth2-bearer":
661
+ config.authtype |= CURLAUTH_BEARER;
662
+ break;
663
+ case "unix-socket":
664
+ case "abstract-unix-socket":
665
+ // Ignore distinction
666
+ // TODO: this makes the error message wrong
667
+ // TODO: what's the difference?
668
+ pushProp(config, "unix-socket", value);
669
+ break;
670
+ case "trace":
671
+ case "trace-ascii":
672
+ case "stderr":
673
+ case "libcurl":
674
+ case "config":
675
+ case "parallel-max":
676
+ global_[argName] = value;
677
+ break;
678
+ case "language": // --language is a curlconverter specific option
679
+ global_[argName] = value.toString();
680
+ return;
681
+ }
682
+ return pushProp(config, argName, value);
683
+ }
684
+ // Might create a new config
685
+ function setArgValue(global_, config, argName, toggle) {
686
+ switch (argName) {
687
+ case "digest":
688
+ if (toggle) {
689
+ config.authtype |= CURLAUTH_DIGEST;
690
+ }
691
+ else {
692
+ config.authtype &= ~CURLAUTH_DIGEST;
693
+ }
694
+ break;
695
+ case "proxy-digest":
696
+ if (toggle) {
697
+ config.proxyauthtype |= CURLAUTH_DIGEST;
698
+ }
699
+ else {
700
+ config.proxyauthtype &= ~CURLAUTH_DIGEST;
701
+ }
702
+ break;
703
+ case "negotiate":
704
+ if (toggle) {
705
+ config.authtype |= CURLAUTH_NEGOTIATE;
706
+ }
707
+ else {
708
+ config.authtype &= ~CURLAUTH_NEGOTIATE;
709
+ }
710
+ break;
711
+ case "proxy-negotiate":
712
+ if (toggle) {
713
+ config.proxyauthtype |= CURLAUTH_NEGOTIATE;
714
+ }
715
+ else {
716
+ config.proxyauthtype &= ~CURLAUTH_NEGOTIATE;
717
+ }
718
+ break;
719
+ case "ntlm":
720
+ if (toggle) {
721
+ config.authtype |= CURLAUTH_NTLM;
722
+ }
723
+ else {
724
+ config.authtype &= ~CURLAUTH_NTLM;
725
+ }
726
+ break;
727
+ case "proxy-ntlm":
728
+ if (toggle) {
729
+ config.proxyauthtype |= CURLAUTH_NTLM;
730
+ }
731
+ else {
732
+ config.proxyauthtype &= ~CURLAUTH_NTLM;
733
+ }
734
+ break;
735
+ case "ntlm-wb":
736
+ if (toggle) {
737
+ config.authtype |= CURLAUTH_NTLM_WB;
738
+ }
739
+ else {
740
+ config.authtype &= ~CURLAUTH_NTLM_WB;
741
+ }
742
+ break;
743
+ case "basic":
744
+ if (toggle) {
745
+ config.authtype |= CURLAUTH_BASIC;
746
+ }
747
+ else {
748
+ config.authtype &= ~CURLAUTH_BASIC;
749
+ }
750
+ break;
751
+ case "proxy-basic":
752
+ if (toggle) {
753
+ config.proxyauthtype |= CURLAUTH_BASIC;
754
+ }
755
+ else {
756
+ config.proxyauthtype &= ~CURLAUTH_BASIC;
757
+ }
758
+ break;
759
+ case "anyauth":
760
+ if (toggle) {
761
+ config.authtype = CURLAUTH_ANY;
762
+ }
763
+ break;
764
+ case "proxy-anyauth":
765
+ if (toggle) {
766
+ config.proxyauthtype = CURLAUTH_ANY;
767
+ }
768
+ break;
769
+ case "location":
770
+ config["location"] = toggle;
771
+ break;
772
+ case "location-trusted":
773
+ config["location"] = toggle;
774
+ config["location-trusted"] = toggle;
775
+ break;
776
+ case "http1.0":
777
+ config.httpVersion = "1.0";
778
+ break;
779
+ case "http1.1":
780
+ config.httpVersion = "1.1";
781
+ break;
782
+ case "http2":
783
+ config.httpVersion = "2";
784
+ break;
785
+ case "http2-prior-knowledge":
786
+ config.httpVersion = "2-prior-knowledge";
787
+ break;
788
+ case "http3":
789
+ config.httpVersion = "3";
790
+ break;
791
+ case "http3-only":
792
+ config.httpVersion = "3-only";
793
+ break;
794
+ case "tlsv1":
795
+ config.tlsVersion = "1";
796
+ break;
797
+ case "tlsv1.0":
798
+ config.tlsVersion = "1.0";
799
+ break;
800
+ case "tlsv1.1":
801
+ config.tlsVersion = "1.1";
802
+ break;
803
+ case "tlsv1.2":
804
+ config.tlsVersion = "1.2";
805
+ break;
806
+ case "tlsv1.3":
807
+ config.tlsVersion = "1.3";
808
+ break;
809
+ case "verbose":
810
+ case "version":
811
+ case "trace-time":
812
+ case "test-event":
813
+ case "progress-bar":
814
+ case "progress-meter":
815
+ case "fail-early":
816
+ case "styled-output":
817
+ case "help":
818
+ case "silent":
819
+ case "show-error":
820
+ case "parallel":
821
+ case "parallel-immediate":
822
+ case "stdin": // --stdin or - is a curlconverter specific option
823
+ global_[argName] = toggle;
824
+ break;
825
+ case "next":
826
+ // curl ignores --next if the last url node doesn't have a url
827
+ if (toggle &&
828
+ config.url &&
829
+ config.url.length > 0 &&
830
+ config.url.length >= (config["upload-file"] || []).length &&
831
+ config.url.length >= (config.output || []).length) {
832
+ config = { authtype: CURLAUTH_BASIC, proxyauthtype: CURLAUTH_BASIC };
833
+ global_.configs.push(config);
834
+ }
835
+ break;
836
+ default:
837
+ config[argName] = toggle;
838
+ }
839
+ return config;
840
+ }
841
+ export function parseArgs(args, longOpts = curlLongOpts, shortenedLongOpts = curlLongOptsShortened, shortOpts = curlShortOpts, supportedOpts, warnings = []) {
842
+ let config = {
843
+ authtype: CURLAUTH_BASIC,
844
+ proxyauthtype: CURLAUTH_BASIC,
845
+ };
846
+ const global_ = { configs: [config], warnings };
847
+ const seen = [];
848
+ for (let i = 1, stillflags = true; i < args.length; i++) {
849
+ const arg = args[i];
850
+ if (stillflags && arg.startsWith("-")) {
851
+ if (eq(arg, "--")) {
852
+ /* This indicates the end of the flags and thus enables the
853
+ following (URL) argument to start with -. */
854
+ stillflags = false;
855
+ }
856
+ else if (arg.startsWith("--")) {
857
+ const shellToken = firstShellToken(arg);
858
+ if (shellToken) {
859
+ // TODO: if there's any text after the "--" or after the variable
860
+ // we could narrow it down.
861
+ throw new CCError("this " +
862
+ shellToken.type +
863
+ " could " +
864
+ (shellToken.type === "command" ? "return" : "be") +
865
+ " anything\n" +
866
+ underlineNode(shellToken.syntaxNode));
867
+ }
868
+ const argStr = arg.toString();
869
+ const lookup = argStr.slice(2);
870
+ let longArg = shortenedLongOpts[lookup];
871
+ if (typeof longArg === "undefined") {
872
+ longArg = longOpts[lookup];
873
+ }
874
+ if (longArg === null) {
875
+ throw new CCError("option " + argStr + ": is ambiguous");
876
+ }
877
+ if (typeof longArg === "undefined") {
878
+ // TODO: extract a list of deleted arguments to check here
879
+ throw new CCError("option " + argStr + ": is unknown");
880
+ }
881
+ if (longArg.type === "string") {
882
+ i++;
883
+ if (i >= args.length) {
884
+ throw new CCError("option " + argStr + ": requires parameter");
885
+ }
886
+ pushArgValue(global_, config, longArg.name, args[i]);
887
+ }
888
+ else {
889
+ config = setArgValue(global_, config, longArg.name, toBoolean(argStr.slice(2))); // TODO: all shortened args work correctly?
890
+ }
891
+ checkSupported(global_, argStr, longArg, supportedOpts);
892
+ seen.push([longArg.name, argStr]);
893
+ }
894
+ else {
895
+ // Short option. These can look like
896
+ // -X POST -> {request: 'POST'}
897
+ // or
898
+ // -XPOST -> {request: 'POST'}
899
+ // or multiple options
900
+ // -ABCX POST -> {A: true, B: true, C: true, request: 'POST'}
901
+ // or multiple options and a value for the last one
902
+ // -ABCXPOST -> {A: true, B: true, C: true, request: 'POST'}
903
+ // "-" passed to curl as an argument raises an error,
904
+ // curlconverter's command line uses it to read from stdin
905
+ if (arg.length === 1) {
906
+ if (Object.prototype.hasOwnProperty.call(shortOpts, "")) {
907
+ const shortFor = shortOpts[""];
908
+ const longArg = longOpts[shortFor];
909
+ if (longArg === null) {
910
+ throw new CCError("option -: is unknown");
911
+ }
912
+ config = setArgValue(global_, config, longArg.name, toBoolean(shortFor));
913
+ seen.push([longArg.name, "-"]);
914
+ }
915
+ else {
916
+ throw new CCError("option -: is unknown");
917
+ }
918
+ }
919
+ for (let j = 1; j < arg.length; j++) {
920
+ const jthChar = arg.get(j);
921
+ if (typeof jthChar !== "string") {
922
+ // A bash variable in the middle of a short option
923
+ throw new CCError("this " +
924
+ jthChar.type +
925
+ " could " +
926
+ (jthChar.type === "command" ? "return" : "be") +
927
+ " anything\n" +
928
+ underlineNode(jthChar.syntaxNode));
929
+ }
930
+ if (!has(shortOpts, jthChar)) {
931
+ if (has(changedShortOpts, jthChar)) {
932
+ throw new CCError("option " + arg + ": " + changedShortOpts[jthChar]);
933
+ }
934
+ // TODO: there are a few deleted short options we could report
935
+ throw new CCError("option " + arg + ": is unknown");
936
+ }
937
+ const lookup = jthChar;
938
+ const shortFor = shortOpts[lookup];
939
+ const longArg = longOpts[shortFor];
940
+ if (longArg === null) {
941
+ // This could happen if curlShortOpts points to a renamed option or has a typo
942
+ throw new CCError("ambiguous short option -" + jthChar);
943
+ }
944
+ if (longArg.type === "string") {
945
+ let val;
946
+ if (j + 1 < arg.length) {
947
+ // treat -XPOST as -X POST
948
+ val = arg.slice(j + 1);
949
+ j = arg.length;
950
+ }
951
+ else if (i + 1 < args.length) {
952
+ i++;
953
+ val = args[i];
954
+ }
955
+ else {
956
+ throw new CCError("option " + arg.toString() + ": requires parameter");
957
+ }
958
+ pushArgValue(global_, config, longArg.name, val);
959
+ }
960
+ else {
961
+ // Use shortFor because -N is short for --no-buffer
962
+ // and we want to end up with {buffer: false}
963
+ config = setArgValue(global_, config, longArg.name, toBoolean(shortFor));
964
+ }
965
+ if (lookup) {
966
+ checkSupported(global_, "-" + lookup, longArg, supportedOpts);
967
+ seen.push([longArg.name, "-" + lookup]);
968
+ }
969
+ }
970
+ }
971
+ }
972
+ else {
973
+ if (typeof arg !== "string" &&
974
+ arg.tokens.length &&
975
+ typeof arg.tokens[0] !== "string") {
976
+ const isOrBeginsWith = arg.tokens.length === 1 ? "is" : "begins with";
977
+ warnings.push([
978
+ "ambiguous argument",
979
+ "argument " +
980
+ isOrBeginsWith +
981
+ " a " +
982
+ arg.tokens[0].type +
983
+ ", assuming it's a URL\n" +
984
+ underlineNode(arg.tokens[0].syntaxNode),
985
+ ]);
986
+ }
987
+ pushArgValue(global_, config, "url", arg);
988
+ seen.push(["url", "--url"]);
989
+ }
990
+ }
991
+ for (const cfg of global_.configs) {
992
+ for (const [arg, values] of Object.entries(cfg)) {
993
+ if (Array.isArray(values) && !canBeList.has(arg)) {
994
+ cfg[arg] = values[values.length - 1];
995
+ }
996
+ }
997
+ }
998
+ return [global_, seen];
999
+ }
1000
+ //# sourceMappingURL=opts.js.map