rbs 4.1.0.pre.2-java

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 (574) hide show
  1. checksums.yaml +7 -0
  2. data/.clang-format +75 -0
  3. data/.clangd +2 -0
  4. data/.github/dependabot.yml +24 -0
  5. data/.github/workflows/bundle-update.yml +63 -0
  6. data/.github/workflows/c-check.yml +61 -0
  7. data/.github/workflows/comments.yml +37 -0
  8. data/.github/workflows/dependabot.yml +30 -0
  9. data/.github/workflows/jruby.yml +67 -0
  10. data/.github/workflows/milestone.yml +83 -0
  11. data/.github/workflows/ruby.yml +158 -0
  12. data/.github/workflows/rust.yml +184 -0
  13. data/.github/workflows/truffleruby.yml +54 -0
  14. data/.github/workflows/typecheck.yml +39 -0
  15. data/.github/workflows/wasm.yml +53 -0
  16. data/.github/workflows/windows.yml +49 -0
  17. data/.gitignore +38 -0
  18. data/.rubocop.yml +72 -0
  19. data/BSDL +22 -0
  20. data/CHANGELOG.md +2292 -0
  21. data/COPYING +56 -0
  22. data/README.md +240 -0
  23. data/Rakefile +869 -0
  24. data/Steepfile +53 -0
  25. data/config.yml +913 -0
  26. data/core/array.rbs +4142 -0
  27. data/core/basic_object.rbs +376 -0
  28. data/core/binding.rbs +148 -0
  29. data/core/builtin.rbs +278 -0
  30. data/core/class.rbs +223 -0
  31. data/core/comparable.rbs +192 -0
  32. data/core/complex.rbs +812 -0
  33. data/core/constants.rbs +96 -0
  34. data/core/data.rbs +415 -0
  35. data/core/dir.rbs +993 -0
  36. data/core/encoding.rbs +1368 -0
  37. data/core/enumerable.rbs +2506 -0
  38. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  39. data/core/enumerator/product.rbs +92 -0
  40. data/core/enumerator.rbs +705 -0
  41. data/core/env.rbs +6 -0
  42. data/core/errno.rbs +682 -0
  43. data/core/errors.rbs +789 -0
  44. data/core/exception.rbs +485 -0
  45. data/core/false_class.rbs +82 -0
  46. data/core/fiber.rbs +570 -0
  47. data/core/fiber_error.rbs +11 -0
  48. data/core/file.rbs +2045 -0
  49. data/core/file_constants.rbs +463 -0
  50. data/core/file_stat.rbs +534 -0
  51. data/core/file_test.rbs +331 -0
  52. data/core/float.rbs +1316 -0
  53. data/core/gc.rbs +788 -0
  54. data/core/global_variables.rbs +184 -0
  55. data/core/hash.rbs +2183 -0
  56. data/core/integer.rbs +1374 -0
  57. data/core/io/buffer.rbs +995 -0
  58. data/core/io/wait.rbs +48 -0
  59. data/core/io.rbs +3472 -0
  60. data/core/kernel.rbs +3172 -0
  61. data/core/marshal.rbs +207 -0
  62. data/core/match_data.rbs +637 -0
  63. data/core/math.rbs +770 -0
  64. data/core/method.rbs +422 -0
  65. data/core/module.rbs +1856 -0
  66. data/core/nil_class.rbs +210 -0
  67. data/core/numeric.rbs +832 -0
  68. data/core/object.rbs +108 -0
  69. data/core/object_space/weak_key_map.rbs +166 -0
  70. data/core/object_space.rbs +197 -0
  71. data/core/pathname.rbs +1322 -0
  72. data/core/proc.rbs +905 -0
  73. data/core/process.rbs +2316 -0
  74. data/core/ractor.rbs +924 -0
  75. data/core/random.rbs +255 -0
  76. data/core/range.rbs +1209 -0
  77. data/core/rational.rbs +502 -0
  78. data/core/rb_config.rbs +88 -0
  79. data/core/rbs/ops.rbs +154 -0
  80. data/core/rbs/unnamed/argf.rbs +1236 -0
  81. data/core/rbs/unnamed/env_class.rbs +1214 -0
  82. data/core/rbs/unnamed/main_class.rbs +123 -0
  83. data/core/rbs/unnamed/random.rbs +186 -0
  84. data/core/refinement.rbs +59 -0
  85. data/core/regexp.rbs +1974 -0
  86. data/core/ruby.rbs +53 -0
  87. data/core/ruby_vm.rbs +809 -0
  88. data/core/rubygems/basic_specification.rbs +6 -0
  89. data/core/rubygems/config_file.rbs +38 -0
  90. data/core/rubygems/dependency_installer.rbs +6 -0
  91. data/core/rubygems/errors.rbs +109 -0
  92. data/core/rubygems/installer.rbs +15 -0
  93. data/core/rubygems/path_support.rbs +6 -0
  94. data/core/rubygems/platform.rbs +7 -0
  95. data/core/rubygems/request_set.rbs +49 -0
  96. data/core/rubygems/requirement.rbs +148 -0
  97. data/core/rubygems/rubygems.rbs +1105 -0
  98. data/core/rubygems/source_list.rbs +15 -0
  99. data/core/rubygems/specification.rbs +23 -0
  100. data/core/rubygems/stream_ui.rbs +5 -0
  101. data/core/rubygems/uninstaller.rbs +10 -0
  102. data/core/rubygems/version.rbs +293 -0
  103. data/core/set.rbs +751 -0
  104. data/core/signal.rbs +110 -0
  105. data/core/string.rbs +5532 -0
  106. data/core/struct.rbs +668 -0
  107. data/core/symbol.rbs +482 -0
  108. data/core/thread.rbs +1826 -0
  109. data/core/thread_group.rbs +79 -0
  110. data/core/time.rbs +1793 -0
  111. data/core/trace_point.rbs +483 -0
  112. data/core/true_class.rbs +98 -0
  113. data/core/unbound_method.rbs +337 -0
  114. data/core/warning.rbs +87 -0
  115. data/docs/CONTRIBUTING.md +107 -0
  116. data/docs/aliases.md +79 -0
  117. data/docs/architecture.md +110 -0
  118. data/docs/collection.md +192 -0
  119. data/docs/config.md +171 -0
  120. data/docs/data_and_struct.md +86 -0
  121. data/docs/encoding.md +56 -0
  122. data/docs/gem.md +56 -0
  123. data/docs/inline.md +634 -0
  124. data/docs/rbs_by_example.md +309 -0
  125. data/docs/repo.md +125 -0
  126. data/docs/rust.md +96 -0
  127. data/docs/sigs.md +167 -0
  128. data/docs/stdlib.md +147 -0
  129. data/docs/syntax.md +940 -0
  130. data/docs/tools.md +17 -0
  131. data/docs/type_fingerprint.md +21 -0
  132. data/docs/wasm_serialization.md +80 -0
  133. data/exe/rbs +7 -0
  134. data/ext/rbs_extension/ast_translation.c +1855 -0
  135. data/ext/rbs_extension/ast_translation.h +41 -0
  136. data/ext/rbs_extension/class_constants.c +187 -0
  137. data/ext/rbs_extension/class_constants.h +104 -0
  138. data/ext/rbs_extension/compat.h +10 -0
  139. data/ext/rbs_extension/extconf.rb +40 -0
  140. data/ext/rbs_extension/legacy_location.c +294 -0
  141. data/ext/rbs_extension/legacy_location.h +82 -0
  142. data/ext/rbs_extension/main.c +613 -0
  143. data/ext/rbs_extension/rbs_extension.h +16 -0
  144. data/ext/rbs_extension/rbs_string_bridging.c +9 -0
  145. data/ext/rbs_extension/rbs_string_bridging.h +24 -0
  146. data/goodcheck.yml +91 -0
  147. data/include/rbs/ast.h +1047 -0
  148. data/include/rbs/defines.h +99 -0
  149. data/include/rbs/lexer.h +207 -0
  150. data/include/rbs/location.h +40 -0
  151. data/include/rbs/parser.h +153 -0
  152. data/include/rbs/serialize.h +39 -0
  153. data/include/rbs/string.h +47 -0
  154. data/include/rbs/util/rbs_allocator.h +59 -0
  155. data/include/rbs/util/rbs_assert.h +20 -0
  156. data/include/rbs/util/rbs_buffer.h +83 -0
  157. data/include/rbs/util/rbs_constant_pool.h +155 -0
  158. data/include/rbs/util/rbs_encoding.h +282 -0
  159. data/include/rbs/util/rbs_unescape.h +24 -0
  160. data/include/rbs.h +14 -0
  161. data/lib/rbs/ancestor_graph.rb +92 -0
  162. data/lib/rbs/annotate/annotations.rb +199 -0
  163. data/lib/rbs/annotate/formatter.rb +82 -0
  164. data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
  165. data/lib/rbs/annotate/rdoc_source.rb +131 -0
  166. data/lib/rbs/annotate.rb +8 -0
  167. data/lib/rbs/ast/annotation.rb +29 -0
  168. data/lib/rbs/ast/comment.rb +29 -0
  169. data/lib/rbs/ast/declarations.rb +472 -0
  170. data/lib/rbs/ast/directives.rb +49 -0
  171. data/lib/rbs/ast/members.rb +451 -0
  172. data/lib/rbs/ast/ruby/annotations.rb +451 -0
  173. data/lib/rbs/ast/ruby/comment_block.rb +247 -0
  174. data/lib/rbs/ast/ruby/declarations.rb +291 -0
  175. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +28 -0
  176. data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
  177. data/lib/rbs/ast/ruby/members.rb +762 -0
  178. data/lib/rbs/ast/type_param.rb +235 -0
  179. data/lib/rbs/ast/visitor.rb +137 -0
  180. data/lib/rbs/buffer.rb +189 -0
  181. data/lib/rbs/builtin_names.rb +58 -0
  182. data/lib/rbs/cli/colored_io.rb +48 -0
  183. data/lib/rbs/cli/diff.rb +84 -0
  184. data/lib/rbs/cli/validate.rb +294 -0
  185. data/lib/rbs/cli.rb +1253 -0
  186. data/lib/rbs/collection/cleaner.rb +38 -0
  187. data/lib/rbs/collection/config/lockfile.rb +92 -0
  188. data/lib/rbs/collection/config/lockfile_generator.rb +269 -0
  189. data/lib/rbs/collection/config.rb +81 -0
  190. data/lib/rbs/collection/installer.rb +32 -0
  191. data/lib/rbs/collection/sources/base.rb +14 -0
  192. data/lib/rbs/collection/sources/git.rb +265 -0
  193. data/lib/rbs/collection/sources/local.rb +81 -0
  194. data/lib/rbs/collection/sources/rubygems.rb +48 -0
  195. data/lib/rbs/collection/sources/stdlib.rb +50 -0
  196. data/lib/rbs/collection/sources.rb +38 -0
  197. data/lib/rbs/collection.rb +16 -0
  198. data/lib/rbs/constant.rb +28 -0
  199. data/lib/rbs/definition.rb +415 -0
  200. data/lib/rbs/definition_builder/ancestor_builder.rb +678 -0
  201. data/lib/rbs/definition_builder/method_builder.rb +295 -0
  202. data/lib/rbs/definition_builder.rb +1054 -0
  203. data/lib/rbs/diff.rb +131 -0
  204. data/lib/rbs/environment/class_entry.rb +69 -0
  205. data/lib/rbs/environment/module_entry.rb +66 -0
  206. data/lib/rbs/environment/use_map.rb +77 -0
  207. data/lib/rbs/environment.rb +1028 -0
  208. data/lib/rbs/environment_loader.rb +167 -0
  209. data/lib/rbs/environment_walker.rb +155 -0
  210. data/lib/rbs/errors.rb +634 -0
  211. data/lib/rbs/factory.rb +18 -0
  212. data/lib/rbs/file_finder.rb +28 -0
  213. data/lib/rbs/inline_parser/comment_association.rb +117 -0
  214. data/lib/rbs/inline_parser.rb +568 -0
  215. data/lib/rbs/location_aux.rb +170 -0
  216. data/lib/rbs/locator.rb +247 -0
  217. data/lib/rbs/method_type.rb +145 -0
  218. data/lib/rbs/namespace.rb +154 -0
  219. data/lib/rbs/parser/lex_result.rb +15 -0
  220. data/lib/rbs/parser/token.rb +23 -0
  221. data/lib/rbs/parser_aux.rb +142 -0
  222. data/lib/rbs/prototype/helpers.rb +197 -0
  223. data/lib/rbs/prototype/node_usage.rb +99 -0
  224. data/lib/rbs/prototype/rb.rb +816 -0
  225. data/lib/rbs/prototype/rbi.rb +625 -0
  226. data/lib/rbs/prototype/runtime/helpers.rb +59 -0
  227. data/lib/rbs/prototype/runtime/reflection.rb +19 -0
  228. data/lib/rbs/prototype/runtime/value_object_generator.rb +279 -0
  229. data/lib/rbs/prototype/runtime.rb +680 -0
  230. data/lib/rbs/repository.rb +127 -0
  231. data/lib/rbs/resolver/constant_resolver.rb +219 -0
  232. data/lib/rbs/resolver/type_name_resolver.rb +167 -0
  233. data/lib/rbs/rewriter.rb +70 -0
  234. data/lib/rbs/sorter.rb +198 -0
  235. data/lib/rbs/source.rb +99 -0
  236. data/lib/rbs/substitution.rb +83 -0
  237. data/lib/rbs/subtractor.rb +204 -0
  238. data/lib/rbs/test/errors.rb +80 -0
  239. data/lib/rbs/test/guaranteed.rb +30 -0
  240. data/lib/rbs/test/hook.rb +212 -0
  241. data/lib/rbs/test/observer.rb +19 -0
  242. data/lib/rbs/test/setup.rb +84 -0
  243. data/lib/rbs/test/setup_helper.rb +50 -0
  244. data/lib/rbs/test/tester.rb +167 -0
  245. data/lib/rbs/test/type_check.rb +457 -0
  246. data/lib/rbs/test.rb +112 -0
  247. data/lib/rbs/type_alias_dependency.rb +100 -0
  248. data/lib/rbs/type_alias_regularity.rb +126 -0
  249. data/lib/rbs/type_name.rb +122 -0
  250. data/lib/rbs/types.rb +1604 -0
  251. data/lib/rbs/unit_test/convertibles.rb +177 -0
  252. data/lib/rbs/unit_test/spy.rb +138 -0
  253. data/lib/rbs/unit_test/type_assertions.rb +383 -0
  254. data/lib/rbs/unit_test/with_aliases.rb +145 -0
  255. data/lib/rbs/unit_test.rb +6 -0
  256. data/lib/rbs/validator.rb +186 -0
  257. data/lib/rbs/variance_calculator.rb +189 -0
  258. data/lib/rbs/vendorer.rb +71 -0
  259. data/lib/rbs/version.rb +5 -0
  260. data/lib/rbs/wasm/deserializer.rb +213 -0
  261. data/lib/rbs/wasm/jars/asm-analysis.jar +0 -0
  262. data/lib/rbs/wasm/jars/asm-commons.jar +0 -0
  263. data/lib/rbs/wasm/jars/asm-tree.jar +0 -0
  264. data/lib/rbs/wasm/jars/asm-util.jar +0 -0
  265. data/lib/rbs/wasm/jars/asm.jar +0 -0
  266. data/lib/rbs/wasm/jars/compiler.jar +0 -0
  267. data/lib/rbs/wasm/jars/log.jar +0 -0
  268. data/lib/rbs/wasm/jars/runtime.jar +0 -0
  269. data/lib/rbs/wasm/jars/wasi.jar +0 -0
  270. data/lib/rbs/wasm/jars/wasm.jar +0 -0
  271. data/lib/rbs/wasm/location.rb +61 -0
  272. data/lib/rbs/wasm/parser.rb +137 -0
  273. data/lib/rbs/wasm/rbs_parser.wasm +0 -0
  274. data/lib/rbs/wasm/runtime.rb +217 -0
  275. data/lib/rbs/wasm/serialization_schema.rb +110 -0
  276. data/lib/rbs/writer.rb +424 -0
  277. data/lib/rbs.rb +117 -0
  278. data/lib/rdoc/discover.rb +20 -0
  279. data/lib/rdoc_plugin/parser.rb +163 -0
  280. data/rbs.gemspec +68 -0
  281. data/schema/annotation.json +14 -0
  282. data/schema/comment.json +26 -0
  283. data/schema/decls.json +326 -0
  284. data/schema/function.json +87 -0
  285. data/schema/location.json +56 -0
  286. data/schema/members.json +266 -0
  287. data/schema/methodType.json +50 -0
  288. data/schema/typeParam.json +52 -0
  289. data/schema/types.json +317 -0
  290. data/sig/ancestor_builder.rbs +163 -0
  291. data/sig/ancestor_graph.rbs +60 -0
  292. data/sig/annotate/annotations.rbs +102 -0
  293. data/sig/annotate/formatter.rbs +24 -0
  294. data/sig/annotate/rdoc_annotater.rbs +85 -0
  295. data/sig/annotate/rdoc_source.rbs +32 -0
  296. data/sig/annotation.rbs +27 -0
  297. data/sig/ast/ruby/annotations.rbs +470 -0
  298. data/sig/ast/ruby/comment_block.rbs +127 -0
  299. data/sig/ast/ruby/declarations.rbs +158 -0
  300. data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
  301. data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
  302. data/sig/ast/ruby/members.rbs +198 -0
  303. data/sig/buffer.rbs +108 -0
  304. data/sig/builtin_names.rbs +44 -0
  305. data/sig/cli/colored_io.rbs +15 -0
  306. data/sig/cli/diff.rbs +15 -0
  307. data/sig/cli/validate.rbs +47 -0
  308. data/sig/cli.rbs +89 -0
  309. data/sig/collection/cleaner.rbs +13 -0
  310. data/sig/collection/config/lockfile.rbs +74 -0
  311. data/sig/collection/config/lockfile_generator.rbs +68 -0
  312. data/sig/collection/config.rbs +46 -0
  313. data/sig/collection/installer.rbs +17 -0
  314. data/sig/collection/sources.rbs +214 -0
  315. data/sig/collection.rbs +4 -0
  316. data/sig/comment.rbs +26 -0
  317. data/sig/constant.rbs +21 -0
  318. data/sig/declarations.rbs +274 -0
  319. data/sig/definition.rbs +232 -0
  320. data/sig/definition_builder.rbs +181 -0
  321. data/sig/diff.rbs +28 -0
  322. data/sig/directives.rbs +77 -0
  323. data/sig/environment/class_entry.rbs +50 -0
  324. data/sig/environment/module_entry.rbs +50 -0
  325. data/sig/environment.rbs +286 -0
  326. data/sig/environment_loader.rbs +111 -0
  327. data/sig/environment_walker.rbs +65 -0
  328. data/sig/errors.rbs +408 -0
  329. data/sig/factory.rbs +5 -0
  330. data/sig/file_finder.rbs +28 -0
  331. data/sig/inline_parser/comment_association.rbs +71 -0
  332. data/sig/inline_parser.rbs +126 -0
  333. data/sig/location.rbs +135 -0
  334. data/sig/locator.rbs +56 -0
  335. data/sig/manifest.yaml +5 -0
  336. data/sig/members.rbs +258 -0
  337. data/sig/method_builder.rbs +89 -0
  338. data/sig/method_types.rbs +58 -0
  339. data/sig/namespace.rbs +161 -0
  340. data/sig/parser.rbs +164 -0
  341. data/sig/prototype/helpers.rbs +29 -0
  342. data/sig/prototype/node_usage.rbs +20 -0
  343. data/sig/prototype/rb.rbs +96 -0
  344. data/sig/prototype/rbi.rbs +75 -0
  345. data/sig/prototype/runtime.rbs +182 -0
  346. data/sig/rbs.rbs +21 -0
  347. data/sig/rdoc/rbs.rbs +67 -0
  348. data/sig/repository.rbs +85 -0
  349. data/sig/resolver/constant_resolver.rbs +92 -0
  350. data/sig/resolver/context.rbs +34 -0
  351. data/sig/resolver/type_name_resolver.rbs +61 -0
  352. data/sig/rewriter.rbs +45 -0
  353. data/sig/shims/bundler.rbs +38 -0
  354. data/sig/shims/enumerable.rbs +5 -0
  355. data/sig/shims/rubygems.rbs +19 -0
  356. data/sig/sorter.rbs +41 -0
  357. data/sig/source.rbs +48 -0
  358. data/sig/substitution.rbs +48 -0
  359. data/sig/subtractor.rbs +37 -0
  360. data/sig/test/errors.rbs +52 -0
  361. data/sig/test/guranteed.rbs +9 -0
  362. data/sig/test/type_check.rbs +19 -0
  363. data/sig/test.rbs +82 -0
  364. data/sig/type_alias_dependency.rbs +53 -0
  365. data/sig/type_alias_regularity.rbs +98 -0
  366. data/sig/type_param.rbs +115 -0
  367. data/sig/typename.rbs +89 -0
  368. data/sig/types.rbs +578 -0
  369. data/sig/unit_test/convertibles.rbs +154 -0
  370. data/sig/unit_test/spy.rbs +22 -0
  371. data/sig/unit_test/type_assertions.rbs +211 -0
  372. data/sig/unit_test/with_aliases.rbs +136 -0
  373. data/sig/use_map.rbs +35 -0
  374. data/sig/util.rbs +9 -0
  375. data/sig/validator.rbs +63 -0
  376. data/sig/variance_calculator.rbs +87 -0
  377. data/sig/vendorer.rbs +51 -0
  378. data/sig/version.rbs +3 -0
  379. data/sig/visitor.rbs +47 -0
  380. data/sig/wasm/deserializer.rbs +66 -0
  381. data/sig/wasm/serialization_schema.rbs +13 -0
  382. data/sig/writer.rbs +127 -0
  383. data/src/ast.c +1628 -0
  384. data/src/lexer.c +3217 -0
  385. data/src/lexer.re +155 -0
  386. data/src/lexstate.c +217 -0
  387. data/src/location.c +31 -0
  388. data/src/parser.c +4255 -0
  389. data/src/serialize.c +958 -0
  390. data/src/string.c +41 -0
  391. data/src/util/rbs_allocator.c +162 -0
  392. data/src/util/rbs_assert.c +19 -0
  393. data/src/util/rbs_buffer.c +54 -0
  394. data/src/util/rbs_constant_pool.c +268 -0
  395. data/src/util/rbs_encoding.c +21308 -0
  396. data/src/util/rbs_unescape.c +167 -0
  397. data/stdlib/abbrev/0/abbrev.rbs +66 -0
  398. data/stdlib/abbrev/0/array.rbs +26 -0
  399. data/stdlib/base64/0/base64.rbs +355 -0
  400. data/stdlib/benchmark/0/benchmark.rbs +452 -0
  401. data/stdlib/bigdecimal/0/big_decimal.rbs +1647 -0
  402. data/stdlib/bigdecimal-math/0/big_math.rbs +280 -0
  403. data/stdlib/bigdecimal-math/0/manifest.yaml +2 -0
  404. data/stdlib/cgi/0/core.rbs +911 -0
  405. data/stdlib/cgi/0/manifest.yaml +4 -0
  406. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  407. data/stdlib/coverage/0/coverage.rbs +266 -0
  408. data/stdlib/csv/0/csv.rbs +3776 -0
  409. data/stdlib/csv/0/manifest.yaml +3 -0
  410. data/stdlib/date/0/date.rbs +1598 -0
  411. data/stdlib/date/0/date_time.rbs +617 -0
  412. data/stdlib/date/0/time.rbs +26 -0
  413. data/stdlib/dbm/0/dbm.rbs +421 -0
  414. data/stdlib/delegate/0/delegator.rbs +187 -0
  415. data/stdlib/delegate/0/kernel.rbs +47 -0
  416. data/stdlib/delegate/0/simple_delegator.rbs +96 -0
  417. data/stdlib/did_you_mean/0/did_you_mean.rbs +344 -0
  418. data/stdlib/digest/0/digest.rbs +687 -0
  419. data/stdlib/erb/0/erb.rbs +933 -0
  420. data/stdlib/etc/0/etc.rbs +884 -0
  421. data/stdlib/fileutils/0/fileutils.rbs +1753 -0
  422. data/stdlib/find/0/find.rbs +49 -0
  423. data/stdlib/forwardable/0/forwardable.rbs +271 -0
  424. data/stdlib/io-console/0/io-console.rbs +414 -0
  425. data/stdlib/ipaddr/0/ipaddr.rbs +436 -0
  426. data/stdlib/json/0/json.rbs +1963 -0
  427. data/stdlib/kconv/0/kconv.rbs +166 -0
  428. data/stdlib/logger/0/formatter.rbs +45 -0
  429. data/stdlib/logger/0/log_device.rbs +100 -0
  430. data/stdlib/logger/0/logger.rbs +796 -0
  431. data/stdlib/logger/0/manifest.yaml +2 -0
  432. data/stdlib/logger/0/period.rbs +17 -0
  433. data/stdlib/logger/0/severity.rbs +34 -0
  434. data/stdlib/minitest/0/kernel.rbs +42 -0
  435. data/stdlib/minitest/0/minitest/abstract_reporter.rbs +52 -0
  436. data/stdlib/minitest/0/minitest/assertion.rbs +17 -0
  437. data/stdlib/minitest/0/minitest/assertions.rbs +590 -0
  438. data/stdlib/minitest/0/minitest/backtrace_filter.rbs +23 -0
  439. data/stdlib/minitest/0/minitest/bench_spec.rbs +102 -0
  440. data/stdlib/minitest/0/minitest/benchmark.rbs +259 -0
  441. data/stdlib/minitest/0/minitest/composite_reporter.rbs +25 -0
  442. data/stdlib/minitest/0/minitest/compress.rbs +13 -0
  443. data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
  444. data/stdlib/minitest/0/minitest/expectation.rbs +2 -0
  445. data/stdlib/minitest/0/minitest/expectations.rbs +21 -0
  446. data/stdlib/minitest/0/minitest/guard.rbs +64 -0
  447. data/stdlib/minitest/0/minitest/mock.rbs +64 -0
  448. data/stdlib/minitest/0/minitest/parallel/executor.rbs +46 -0
  449. data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +5 -0
  450. data/stdlib/minitest/0/minitest/parallel/test.rbs +3 -0
  451. data/stdlib/minitest/0/minitest/parallel.rbs +2 -0
  452. data/stdlib/minitest/0/minitest/pride_io.rbs +62 -0
  453. data/stdlib/minitest/0/minitest/pride_lol.rbs +19 -0
  454. data/stdlib/minitest/0/minitest/progress_reporter.rbs +11 -0
  455. data/stdlib/minitest/0/minitest/reportable.rbs +53 -0
  456. data/stdlib/minitest/0/minitest/reporter.rbs +5 -0
  457. data/stdlib/minitest/0/minitest/result.rbs +28 -0
  458. data/stdlib/minitest/0/minitest/runnable.rbs +163 -0
  459. data/stdlib/minitest/0/minitest/skip.rbs +6 -0
  460. data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +48 -0
  461. data/stdlib/minitest/0/minitest/spec/dsl.rbs +129 -0
  462. data/stdlib/minitest/0/minitest/spec.rbs +11 -0
  463. data/stdlib/minitest/0/minitest/statistics_reporter.rbs +81 -0
  464. data/stdlib/minitest/0/minitest/summary_reporter.rbs +18 -0
  465. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +92 -0
  466. data/stdlib/minitest/0/minitest/test.rbs +69 -0
  467. data/stdlib/minitest/0/minitest/unexpected_error.rbs +12 -0
  468. data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
  469. data/stdlib/minitest/0/minitest/unit/test_case.rbs +3 -0
  470. data/stdlib/minitest/0/minitest/unit.rbs +4 -0
  471. data/stdlib/minitest/0/minitest.rbs +115 -0
  472. data/stdlib/monitor/0/monitor.rbs +363 -0
  473. data/stdlib/mutex_m/0/mutex_m.rbs +104 -0
  474. data/stdlib/net-http/0/manifest.yaml +3 -0
  475. data/stdlib/net-http/0/net-http.rbs +5580 -0
  476. data/stdlib/net-protocol/0/manifest.yaml +2 -0
  477. data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
  478. data/stdlib/net-smtp/0/manifest.yaml +2 -0
  479. data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
  480. data/stdlib/nkf/0/nkf.rbs +402 -0
  481. data/stdlib/objspace/0/objspace.rbs +470 -0
  482. data/stdlib/observable/0/observable.rbs +217 -0
  483. data/stdlib/open-uri/0/manifest.yaml +4 -0
  484. data/stdlib/open-uri/0/open-uri.rbs +433 -0
  485. data/stdlib/open3/0/open3.rbs +606 -0
  486. data/stdlib/openssl/0/manifest.yaml +3 -0
  487. data/stdlib/openssl/0/openssl.rbs +12231 -0
  488. data/stdlib/optparse/0/optparse.rbs +1734 -0
  489. data/stdlib/pathname/0/pathname.rbs +36 -0
  490. data/stdlib/pp/0/manifest.yaml +2 -0
  491. data/stdlib/pp/0/pp.rbs +301 -0
  492. data/stdlib/prettyprint/0/prettyprint.rbs +383 -0
  493. data/stdlib/pstore/0/pstore.rbs +608 -0
  494. data/stdlib/psych/0/core_ext.rbs +12 -0
  495. data/stdlib/psych/0/dbm.rbs +237 -0
  496. data/stdlib/psych/0/manifest.yaml +3 -0
  497. data/stdlib/psych/0/psych.rbs +455 -0
  498. data/stdlib/psych/0/store.rbs +57 -0
  499. data/stdlib/pty/0/pty.rbs +240 -0
  500. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  501. data/stdlib/rdoc/0/code_object.rbs +52 -0
  502. data/stdlib/rdoc/0/comment.rbs +61 -0
  503. data/stdlib/rdoc/0/context.rbs +153 -0
  504. data/stdlib/rdoc/0/markup.rbs +117 -0
  505. data/stdlib/rdoc/0/options.rbs +76 -0
  506. data/stdlib/rdoc/0/parser.rbs +56 -0
  507. data/stdlib/rdoc/0/rdoc.rbs +393 -0
  508. data/stdlib/rdoc/0/ri.rbs +17 -0
  509. data/stdlib/rdoc/0/store.rbs +48 -0
  510. data/stdlib/rdoc/0/top_level.rbs +97 -0
  511. data/stdlib/resolv/0/manifest.yaml +3 -0
  512. data/stdlib/resolv/0/resolv.rbs +1787 -0
  513. data/stdlib/ripper/0/ripper.rbs +1654 -0
  514. data/stdlib/securerandom/0/manifest.yaml +2 -0
  515. data/stdlib/securerandom/0/securerandom.rbs +49 -0
  516. data/stdlib/shellwords/0/shellwords.rbs +229 -0
  517. data/stdlib/singleton/0/singleton.rbs +134 -0
  518. data/stdlib/socket/0/addrinfo.rbs +666 -0
  519. data/stdlib/socket/0/basic_socket.rbs +590 -0
  520. data/stdlib/socket/0/constants.rbs +2295 -0
  521. data/stdlib/socket/0/ip_socket.rbs +94 -0
  522. data/stdlib/socket/0/socket.rbs +4170 -0
  523. data/stdlib/socket/0/socket_error.rbs +5 -0
  524. data/stdlib/socket/0/tcp_server.rbs +192 -0
  525. data/stdlib/socket/0/tcp_socket.rbs +87 -0
  526. data/stdlib/socket/0/udp_socket.rbs +133 -0
  527. data/stdlib/socket/0/unix_server.rbs +169 -0
  528. data/stdlib/socket/0/unix_socket.rbs +172 -0
  529. data/stdlib/stringio/0/stringio.rbs +1681 -0
  530. data/stdlib/strscan/0/string_scanner.rbs +1648 -0
  531. data/stdlib/tempfile/0/tempfile.rbs +483 -0
  532. data/stdlib/time/0/time.rbs +434 -0
  533. data/stdlib/timeout/0/timeout.rbs +137 -0
  534. data/stdlib/tmpdir/0/tmpdir.rbs +69 -0
  535. data/stdlib/tsort/0/cyclic.rbs +8 -0
  536. data/stdlib/tsort/0/interfaces.rbs +20 -0
  537. data/stdlib/tsort/0/tsort.rbs +410 -0
  538. data/stdlib/uri/0/common.rbs +621 -0
  539. data/stdlib/uri/0/file.rbs +118 -0
  540. data/stdlib/uri/0/ftp.rbs +13 -0
  541. data/stdlib/uri/0/generic.rbs +1116 -0
  542. data/stdlib/uri/0/http.rbs +104 -0
  543. data/stdlib/uri/0/https.rbs +14 -0
  544. data/stdlib/uri/0/ldap.rbs +230 -0
  545. data/stdlib/uri/0/ldaps.rbs +14 -0
  546. data/stdlib/uri/0/mailto.rbs +92 -0
  547. data/stdlib/uri/0/rfc2396_parser.rbs +189 -0
  548. data/stdlib/uri/0/rfc3986_parser.rbs +2 -0
  549. data/stdlib/uri/0/ws.rbs +13 -0
  550. data/stdlib/uri/0/wss.rbs +9 -0
  551. data/stdlib/yaml/0/manifest.yaml +2 -0
  552. data/stdlib/yaml/0/yaml.rbs +1 -0
  553. data/stdlib/zlib/0/buf_error.rbs +10 -0
  554. data/stdlib/zlib/0/data_error.rbs +10 -0
  555. data/stdlib/zlib/0/deflate.rbs +211 -0
  556. data/stdlib/zlib/0/error.rbs +20 -0
  557. data/stdlib/zlib/0/gzip_file/crc_error.rbs +12 -0
  558. data/stdlib/zlib/0/gzip_file/error.rbs +23 -0
  559. data/stdlib/zlib/0/gzip_file/length_error.rbs +12 -0
  560. data/stdlib/zlib/0/gzip_file/no_footer.rbs +11 -0
  561. data/stdlib/zlib/0/gzip_file.rbs +156 -0
  562. data/stdlib/zlib/0/gzip_reader.rbs +293 -0
  563. data/stdlib/zlib/0/gzip_writer.rbs +168 -0
  564. data/stdlib/zlib/0/inflate.rbs +180 -0
  565. data/stdlib/zlib/0/mem_error.rbs +10 -0
  566. data/stdlib/zlib/0/need_dict.rbs +13 -0
  567. data/stdlib/zlib/0/stream_end.rbs +11 -0
  568. data/stdlib/zlib/0/stream_error.rbs +11 -0
  569. data/stdlib/zlib/0/version_error.rbs +11 -0
  570. data/stdlib/zlib/0/zlib.rbs +449 -0
  571. data/stdlib/zlib/0/zstream.rbs +201 -0
  572. data/wasm/README.md +59 -0
  573. data/wasm/rbs_wasm.c +411 -0
  574. metadata +660 -0
@@ -0,0 +1,1734 @@
1
+ # <!-- rdoc-file=lib/optparse.rb -->
2
+ # ## OptionParser
3
+ #
4
+ # ### New to `OptionParser`?
5
+ #
6
+ # See the [Tutorial](optparse/tutorial.rdoc).
7
+ #
8
+ # ### Introduction
9
+ #
10
+ # OptionParser is a class for command-line option analysis. It is much more
11
+ # advanced, yet also easier to use, than GetoptLong, and is a more Ruby-oriented
12
+ # solution.
13
+ #
14
+ # ### Features
15
+ #
16
+ # 1. The argument specification and the code to handle it are written in the
17
+ # same place.
18
+ # 2. It can output an option summary; you don't need to maintain this string
19
+ # separately.
20
+ # 3. Optional and mandatory arguments are specified very gracefully.
21
+ # 4. Arguments can be automatically converted to a specified class.
22
+ # 5. Arguments can be restricted to a certain set.
23
+ #
24
+ # All of these features are demonstrated in the examples below. See
25
+ # #make_switch for full documentation.
26
+ #
27
+ # ### Minimal example
28
+ #
29
+ # require 'optparse'
30
+ #
31
+ # options = {}
32
+ # OptionParser.new do |parser|
33
+ # parser.banner = "Usage: example.rb [options]"
34
+ #
35
+ # parser.on("-v", "--[no-]verbose", "Run verbosely") do |v|
36
+ # options[:verbose] = v
37
+ # end
38
+ # end.parse!
39
+ #
40
+ # p options
41
+ # p ARGV
42
+ #
43
+ # ### Generating Help
44
+ #
45
+ # OptionParser can be used to automatically generate help for the commands you
46
+ # write:
47
+ #
48
+ # require 'optparse'
49
+ #
50
+ # Options = Struct.new(:name)
51
+ #
52
+ # class Parser
53
+ # def self.parse(options)
54
+ # args = Options.new("world")
55
+ #
56
+ # opt_parser = OptionParser.new do |parser|
57
+ # parser.banner = "Usage: example.rb [options]"
58
+ #
59
+ # parser.on("-nNAME", "--name=NAME", "Name to say hello to") do |n|
60
+ # args.name = n
61
+ # end
62
+ #
63
+ # parser.on("-h", "--help", "Prints this help") do
64
+ # puts parser
65
+ # exit
66
+ # end
67
+ # end
68
+ #
69
+ # opt_parser.parse!(options)
70
+ # return args
71
+ # end
72
+ # end
73
+ # options = Parser.parse %w[--help]
74
+ #
75
+ # #=>
76
+ # # Usage: example.rb [options]
77
+ # # -n, --name=NAME Name to say hello to
78
+ # # -h, --help Prints this help
79
+ #
80
+ # ### Required Arguments
81
+ #
82
+ # For options that require an argument, option specification strings may include
83
+ # an option name in all caps. If an option is used without the required
84
+ # argument, an exception will be raised.
85
+ #
86
+ # require 'optparse'
87
+ #
88
+ # options = {}
89
+ # OptionParser.new do |parser|
90
+ # parser.on("-r", "--require LIBRARY",
91
+ # "Require the LIBRARY before executing your script") do |lib|
92
+ # puts "You required #{lib}!"
93
+ # end
94
+ # end.parse!
95
+ #
96
+ # Used:
97
+ #
98
+ # $ ruby optparse-test.rb -r
99
+ # optparse-test.rb:9:in '<main>': missing argument: -r (OptionParser::MissingArgument)
100
+ # $ ruby optparse-test.rb -r my-library
101
+ # You required my-library!
102
+ #
103
+ # ### Type Coercion
104
+ #
105
+ # OptionParser supports the ability to coerce command line arguments into
106
+ # objects for us.
107
+ #
108
+ # OptionParser comes with a few ready-to-use kinds of type coercion. They are:
109
+ #
110
+ # * Date -- Anything accepted by <code>Date.parse</code> (need to require
111
+ # <code>optparse/date</code>)
112
+ # * DateTime -- Anything accepted by <code>DateTime.parse</code> (need to
113
+ # require <code>optparse/date</code>)
114
+ # * Time -- Anything accepted by <code>Time.httpdate</code> or
115
+ # <code>Time.parse</code> (need to require <code>optparse/time</code>)
116
+ # * URI -- Anything accepted by <code>URI.parse</code> (need to require
117
+ # <code>optparse/uri</code>)
118
+ # * Shellwords -- Anything accepted by <code>Shellwords.shellwords</code>
119
+ # (need to require <code>optparse/shellwords</code>)
120
+ # * String -- Any non-empty string
121
+ # * Integer -- Any integer. Will convert octal. (e.g. 124, -3, 040)
122
+ # * Float -- Any float. (e.g. 10, 3.14, -100E+13)
123
+ # * Numeric -- Any integer, float, or rational (1, 3.4, 1/3)
124
+ # * DecimalInteger -- Like `Integer`, but no octal format.
125
+ # * OctalInteger -- Like `Integer`, but no decimal format.
126
+ # * DecimalNumeric -- Decimal integer or float.
127
+ # * TrueClass -- Accepts '+, yes, true, -, no, false' and defaults as `true`
128
+ # * FalseClass -- Same as `TrueClass`, but defaults to `false`
129
+ # * Array -- Strings separated by ',' (e.g. 1,2,3)
130
+ # * Regexp -- Regular expressions. Also includes options.
131
+ #
132
+ # We can also add our own coercions, which we will cover below.
133
+ #
134
+ # #### Using Built-in Conversions
135
+ #
136
+ # As an example, the built-in `Time` conversion is used. The other built-in
137
+ # conversions behave in the same way. OptionParser will attempt to parse the
138
+ # argument as a `Time`. If it succeeds, that time will be passed to the handler
139
+ # block. Otherwise, an exception will be raised.
140
+ #
141
+ # require 'optparse'
142
+ # require 'optparse/time'
143
+ # OptionParser.new do |parser|
144
+ # parser.on("-t", "--time [TIME]", Time, "Begin execution at given time") do |time|
145
+ # p time
146
+ # end
147
+ # end.parse!
148
+ #
149
+ # Used:
150
+ #
151
+ # $ ruby optparse-test.rb -t nonsense
152
+ # ... invalid argument: -t nonsense (OptionParser::InvalidArgument)
153
+ # $ ruby optparse-test.rb -t 10-11-12
154
+ # 2010-11-12 00:00:00 -0500
155
+ # $ ruby optparse-test.rb -t 9:30
156
+ # 2014-08-13 09:30:00 -0400
157
+ #
158
+ # #### Creating Custom Conversions
159
+ #
160
+ # The `accept` method on OptionParser may be used to create converters. It
161
+ # specifies which conversion block to call whenever a class is specified. The
162
+ # example below uses it to fetch a `User` object before the `on` handler
163
+ # receives it.
164
+ #
165
+ # require 'optparse'
166
+ #
167
+ # User = Struct.new(:id, :name)
168
+ #
169
+ # def find_user id
170
+ # not_found = ->{ raise "No User Found for id #{id}" }
171
+ # [ User.new(1, "Sam"),
172
+ # User.new(2, "Gandalf") ].find(not_found) do |u|
173
+ # u.id == id
174
+ # end
175
+ # end
176
+ #
177
+ # op = OptionParser.new
178
+ # op.accept(User) do |user_id|
179
+ # find_user user_id.to_i
180
+ # end
181
+ #
182
+ # op.on("--user ID", User) do |user|
183
+ # puts user
184
+ # end
185
+ #
186
+ # op.parse!
187
+ #
188
+ # Used:
189
+ #
190
+ # $ ruby optparse-test.rb --user 1
191
+ # #<struct User id=1, name="Sam">
192
+ # $ ruby optparse-test.rb --user 2
193
+ # #<struct User id=2, name="Gandalf">
194
+ # $ ruby optparse-test.rb --user 3
195
+ # optparse-test.rb:15:in 'block in find_user': No User Found for id 3 (RuntimeError)
196
+ #
197
+ # ### Store options to a Hash
198
+ #
199
+ # The `into` option of `order`, `parse` and so on methods stores command line
200
+ # options into a Hash.
201
+ #
202
+ # require 'optparse'
203
+ #
204
+ # options = {}
205
+ # OptionParser.new do |parser|
206
+ # parser.on('-a')
207
+ # parser.on('-b NUM', Integer)
208
+ # parser.on('-v', '--verbose')
209
+ # end.parse!(into: options)
210
+ #
211
+ # p options
212
+ #
213
+ # Used:
214
+ #
215
+ # $ ruby optparse-test.rb -a
216
+ # {:a=>true}
217
+ # $ ruby optparse-test.rb -a -v
218
+ # {:a=>true, :verbose=>true}
219
+ # $ ruby optparse-test.rb -a -b 100
220
+ # {:a=>true, :b=>100}
221
+ #
222
+ # ### Complete example
223
+ #
224
+ # The following example is a complete Ruby program. You can run it and see the
225
+ # effect of specifying various options. This is probably the best way to learn
226
+ # the features of `optparse`.
227
+ #
228
+ # require 'optparse'
229
+ # require 'optparse/time'
230
+ # require 'ostruct'
231
+ # require 'pp'
232
+ #
233
+ # class OptparseExample
234
+ # Version = '1.0.0'
235
+ #
236
+ # CODES = %w[iso-2022-jp shift_jis euc-jp utf8 binary]
237
+ # CODE_ALIASES = { "jis" => "iso-2022-jp", "sjis" => "shift_jis" }
238
+ #
239
+ # class ScriptOptions
240
+ # attr_accessor :library, :inplace, :encoding, :transfer_type,
241
+ # :verbose, :extension, :delay, :time, :record_separator,
242
+ # :list
243
+ #
244
+ # def initialize
245
+ # self.library = []
246
+ # self.inplace = false
247
+ # self.encoding = "utf8"
248
+ # self.transfer_type = :auto
249
+ # self.verbose = false
250
+ # end
251
+ #
252
+ # def define_options(parser)
253
+ # parser.banner = "Usage: example.rb [options]"
254
+ # parser.separator ""
255
+ # parser.separator "Specific options:"
256
+ #
257
+ # # add additional options
258
+ # perform_inplace_option(parser)
259
+ # delay_execution_option(parser)
260
+ # execute_at_time_option(parser)
261
+ # specify_record_separator_option(parser)
262
+ # list_example_option(parser)
263
+ # specify_encoding_option(parser)
264
+ # optional_option_argument_with_keyword_completion_option(parser)
265
+ # boolean_verbose_option(parser)
266
+ #
267
+ # parser.separator ""
268
+ # parser.separator "Common options:"
269
+ # # No argument, shows at tail. This will print an options summary.
270
+ # # Try it and see!
271
+ # parser.on_tail("-h", "--help", "Show this message") do
272
+ # puts parser
273
+ # exit
274
+ # end
275
+ # # Another typical switch to print the version.
276
+ # parser.on_tail("--version", "Show version") do
277
+ # puts Version
278
+ # exit
279
+ # end
280
+ # end
281
+ #
282
+ # def perform_inplace_option(parser)
283
+ # # Specifies an optional option argument
284
+ # parser.on("-i", "--inplace [EXTENSION]",
285
+ # "Edit ARGV files in place",
286
+ # "(make backup if EXTENSION supplied)") do |ext|
287
+ # self.inplace = true
288
+ # self.extension = ext || ''
289
+ # self.extension.sub!(/\A\.?(?=.)/, ".") # Ensure extension begins with dot.
290
+ # end
291
+ # end
292
+ #
293
+ # def delay_execution_option(parser)
294
+ # # Cast 'delay' argument to a Float.
295
+ # parser.on("--delay N", Float, "Delay N seconds before executing") do |n|
296
+ # self.delay = n
297
+ # end
298
+ # end
299
+ #
300
+ # def execute_at_time_option(parser)
301
+ # # Cast 'time' argument to a Time object.
302
+ # parser.on("-t", "--time [TIME]", Time, "Begin execution at given time") do |time|
303
+ # self.time = time
304
+ # end
305
+ # end
306
+ #
307
+ # def specify_record_separator_option(parser)
308
+ # # Cast to octal integer.
309
+ # parser.on("-F", "--irs [OCTAL]", OptionParser::OctalInteger,
310
+ # "Specify record separator (default \\0)") do |rs|
311
+ # self.record_separator = rs
312
+ # end
313
+ # end
314
+ #
315
+ # def list_example_option(parser)
316
+ # # List of arguments.
317
+ # parser.on("--list x,y,z", Array, "Example 'list' of arguments") do |list|
318
+ # self.list = list
319
+ # end
320
+ # end
321
+ #
322
+ # def specify_encoding_option(parser)
323
+ # # Keyword completion. We are specifying a specific set of arguments (CODES
324
+ # # and CODE_ALIASES - notice the latter is a Hash), and the user may provide
325
+ # # the shortest unambiguous text.
326
+ # code_list = (CODE_ALIASES.keys + CODES).join(', ')
327
+ # parser.on("--code CODE", CODES, CODE_ALIASES, "Select encoding",
328
+ # "(#{code_list})") do |encoding|
329
+ # self.encoding = encoding
330
+ # end
331
+ # end
332
+ #
333
+ # def optional_option_argument_with_keyword_completion_option(parser)
334
+ # # Optional '--type' option argument with keyword completion.
335
+ # parser.on("--type [TYPE]", [:text, :binary, :auto],
336
+ # "Select transfer type (text, binary, auto)") do |t|
337
+ # self.transfer_type = t
338
+ # end
339
+ # end
340
+ #
341
+ # def boolean_verbose_option(parser)
342
+ # # Boolean switch.
343
+ # parser.on("-v", "--[no-]verbose", "Run verbosely") do |v|
344
+ # self.verbose = v
345
+ # end
346
+ # end
347
+ # end
348
+ #
349
+ # #
350
+ # # Return a structure describing the options.
351
+ # #
352
+ # def parse(args)
353
+ # # The options specified on the command line will be collected in
354
+ # # *options*.
355
+ #
356
+ # @options = ScriptOptions.new
357
+ # @args = OptionParser.new do |parser|
358
+ # @options.define_options(parser)
359
+ # parser.parse!(args)
360
+ # end
361
+ # @options
362
+ # end
363
+ #
364
+ # attr_reader :parser, :options
365
+ # end # class OptparseExample
366
+ #
367
+ # example = OptparseExample.new
368
+ # options = example.parse(ARGV)
369
+ # pp options # example.options
370
+ # pp ARGV
371
+ #
372
+ # ### Shell Completion
373
+ #
374
+ # For modern shells (e.g. bash, zsh, etc.), you can use shell completion for
375
+ # command line options.
376
+ #
377
+ # ### Further documentation
378
+ #
379
+ # The above examples, along with the accompanying
380
+ # [Tutorial](optparse/tutorial.rdoc), should be enough to learn how to use this
381
+ # class. If you have any questions, file a ticket at http://bugs.ruby-lang.org.
382
+ #
383
+ class OptionParser
384
+ interface _Pattern
385
+ def match: (untyped other) -> boolish
386
+ end
387
+
388
+ interface _Intoable
389
+ def []=: (Symbol, untyped) -> untyped
390
+ end
391
+
392
+ interface _LtLtString
393
+ def <<: (String) -> untyped
394
+ end
395
+
396
+ # <!--
397
+ # rdoc-file=lib/optparse.rb
398
+ # - accept(*args, &blk)
399
+ # -->
400
+ # See #accept.
401
+ #
402
+ def self.accept: (Class t, ?_Pattern pat) ?{ (*untyped) -> untyped } -> void
403
+
404
+ # <!--
405
+ # rdoc-file=lib/optparse.rb
406
+ # - getopts(*args, symbolize_names: false)
407
+ # -->
408
+ # See #getopts.
409
+ #
410
+ def self.getopts: (*String options) -> Hash[String, untyped]
411
+ | (Array[String] args, *String options) -> Hash[String, untyped]
412
+
413
+ # <!--
414
+ # rdoc-file=lib/optparse.rb
415
+ # - inc(arg, default = nil)
416
+ # -->
417
+ # Returns an incremented value of `default` according to `arg`.
418
+ #
419
+ def self.inc: (untyped arg, ?_ToI default) -> Integer?
420
+
421
+ # <!--
422
+ # rdoc-file=lib/optparse.rb
423
+ # - reject(*args, &blk)
424
+ # -->
425
+ # See #reject.
426
+ #
427
+ def self.reject: (Class t) -> void
428
+
429
+ # <!--
430
+ # rdoc-file=lib/optparse.rb
431
+ # - terminate(arg = nil)
432
+ # -->
433
+ # See #terminate.
434
+ #
435
+ def self.terminate: (?String arg) -> bot
436
+
437
+ # <!--
438
+ # rdoc-file=lib/optparse.rb
439
+ # - top()
440
+ # -->
441
+ # Returns the global top option list.
442
+ #
443
+ # Do not use directly.
444
+ #
445
+ def self.top: () -> OptionParser::List
446
+
447
+ # <!--
448
+ # rdoc-file=lib/optparse.rb
449
+ # - with(*args, &block)
450
+ # -->
451
+ # Initializes a new instance and evaluates the optional block in context of the
452
+ # instance. Arguments `args` are passed to #new, see there for description of
453
+ # parameters.
454
+ #
455
+ # This method is **deprecated**, its behavior corresponds to the older #new
456
+ # method.
457
+ #
458
+ def self.with: (?String banner, ?Integer width, ?String indent) ?{ (instance opts) -> void } -> instance
459
+
460
+ # <!--
461
+ # rdoc-file=lib/optparse.rb
462
+ # - abort(mesg = $!)
463
+ # -->
464
+ # Shows message with the program name then aborts.
465
+ #
466
+ # `mesg`
467
+ # : Message, defaulted to +$!+.
468
+ #
469
+ #
470
+ # See Kernel#abort.
471
+ #
472
+ def abort: (?_ToS mesg) -> bot
473
+
474
+ # <!--
475
+ # rdoc-file=lib/optparse.rb
476
+ # - accept(*args, &blk)
477
+ # -->
478
+ # Directs to accept specified class `t`. The argument string is passed to the
479
+ # block in which it should be converted to the desired class.
480
+ #
481
+ # `t`
482
+ # : Argument class specifier, any object including Class.
483
+ #
484
+ # `pat`
485
+ # : Pattern for argument, defaults to `t` if it responds to match.
486
+ #
487
+ #
488
+ # accept(t, pat, &block)
489
+ #
490
+ def accept: (Class t, ?_Pattern pat) ?{ (*untyped) -> untyped } -> void
491
+
492
+ def add_officious: () -> void
493
+
494
+ # <!--
495
+ # rdoc-file=lib/optparse.rb
496
+ # - additional_message(typ, opt)
497
+ # -->
498
+ # Returns additional info.
499
+ #
500
+ def additional_message: (untyped typ, untyped opt) -> String?
501
+
502
+ # <!-- rdoc-file=lib/optparse.rb -->
503
+ # Heading banner preceding summary.
504
+ #
505
+ attr_accessor banner: String
506
+
507
+ # <!--
508
+ # rdoc-file=lib/optparse.rb
509
+ # - base()
510
+ # -->
511
+ # Subject of #on_tail.
512
+ #
513
+ def base: () -> List
514
+
515
+ # <!--
516
+ # rdoc-file=lib/optparse.rb
517
+ # - candidate(word)
518
+ # -->
519
+ # Return candidates for `word`.
520
+ #
521
+ def candidate: (String word) -> Array[untyped]
522
+
523
+ def compsys: (untyped to, ?untyped name) -> untyped
524
+
525
+ # <!--
526
+ # rdoc-file=lib/optparse.rb
527
+ # - def_head_option(*opts, &block)
528
+ # -->
529
+ #
530
+ alias def_head_option define_head
531
+
532
+ # <!--
533
+ # rdoc-file=lib/optparse.rb
534
+ # - def_option(*opts, &block)
535
+ # -->
536
+ #
537
+ alias def_option define
538
+
539
+ # <!--
540
+ # rdoc-file=lib/optparse.rb
541
+ # - def_tail_option(*opts, &block)
542
+ # -->
543
+ #
544
+ alias def_tail_option define_tail
545
+
546
+ # <!-- rdoc-file=lib/optparse.rb -->
547
+ # Strings to be parsed in default.
548
+ #
549
+ attr_accessor default_argv: Array[String]
550
+
551
+ # <!--
552
+ # rdoc-file=lib/optparse.rb
553
+ # - define(*params, &block)
554
+ # -->
555
+ # Creates an option from the given parameters `params`. See [Parameters for New
556
+ # Options](optparse/option_params.rdoc).
557
+ #
558
+ # The block, if given, is the handler for the created option. When the option is
559
+ # encountered during command-line parsing, the block is called with the argument
560
+ # given for the option, if any. See [Option
561
+ # Handlers](optparse/option_params.rdoc#label-Option+Handlers).
562
+ #
563
+ def define: (*String params) ?{ (*untyped) -> untyped } -> untyped
564
+ | (String params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc) ?{ (*untyped) -> untyped } -> untyped
565
+ | (*String params, Proc | Method handler) -> untyped
566
+ | (String params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc, Proc | Method handler) -> untyped
567
+
568
+ # <!--
569
+ # rdoc-file=lib/optparse.rb
570
+ # - define_head(*params, &block)
571
+ # -->
572
+ # Creates an option from the given parameters `params`. See [Parameters for New
573
+ # Options](optparse/option_params.rdoc).
574
+ #
575
+ # The block, if given, is the handler for the created option. When the option is
576
+ # encountered during command-line parsing, the block is called with the argument
577
+ # given for the option, if any. See [Option
578
+ # Handlers](optparse/option_params.rdoc#label-Option+Handlers).
579
+ #
580
+ def define_head: (*String params) ?{ (*untyped) -> untyped } -> untyped
581
+ | (String params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc) ?{ (*untyped) -> untyped } -> untyped
582
+ | (*String params, Proc | Method handler) -> untyped
583
+ | (String params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc, Proc | Method handler) -> untyped
584
+
585
+ # <!--
586
+ # rdoc-file=lib/optparse.rb
587
+ # - define_tail(*params, &block)
588
+ # -->
589
+ # Creates an option from the given parameters `params`. See [Parameters for New
590
+ # Options](optparse/option_params.rdoc).
591
+ #
592
+ # The block, if given, is the handler for the created option. When the option is
593
+ # encountered during command-line parsing, the block is called with the argument
594
+ # given for the option, if any. See [Option
595
+ # Handlers](optparse/option_params.rdoc#label-Option+Handlers).
596
+ #
597
+ def define_tail: (*String params) ?{ (*untyped) -> untyped } -> untyped
598
+ | (String params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc) ?{ (*untyped) -> untyped } -> untyped
599
+ | (*String params, Proc | Method handler) -> untyped
600
+ | (String params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc, Proc | Method handler) -> untyped
601
+
602
+ # <!--
603
+ # rdoc-file=lib/optparse.rb
604
+ # - environment(env = File.basename($0, '.*'), **keywords)
605
+ # -->
606
+ # Parses environment variable `env` or its uppercase with splitting like a
607
+ # shell.
608
+ #
609
+ # `env` defaults to the basename of the program.
610
+ #
611
+ def environment: (?String env) -> Array[String]?
612
+
613
+ # <!--
614
+ # rdoc-file=lib/optparse.rb
615
+ # - getopts(*args, symbolize_names: false, **keywords)
616
+ # -->
617
+ # Wrapper method for getopts.rb.
618
+ #
619
+ # params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option")
620
+ # # params["a"] = true # -a
621
+ # # params["b"] = "1" # -b1
622
+ # # params["foo"] = "1" # --foo
623
+ # # params["bar"] = "x" # --bar x
624
+ # # params["zot"] = "z" # --zot Z
625
+ #
626
+ # Option `symbolize_names` (boolean) specifies whether returned Hash keys should
627
+ # be Symbols; defaults to `false` (use Strings).
628
+ #
629
+ # params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option", symbolize_names: true)
630
+ # # params[:a] = true # -a
631
+ # # params[:b] = "1" # -b1
632
+ # # params[:foo] = "1" # --foo
633
+ # # params[:bar] = "x" # --bar x
634
+ # # params[:zot] = "z" # --zot Z
635
+ #
636
+ def getopts: (*String options) -> Hash[String, untyped]
637
+ | (Array[String] args, *String options) -> Hash[String, untyped]
638
+
639
+ # <!--
640
+ # rdoc-file=lib/optparse.rb
641
+ # - help()
642
+ # -->
643
+ # Returns option summary string.
644
+ #
645
+ def help: () -> String
646
+
647
+ # <!--
648
+ # rdoc-file=lib/optparse.rb
649
+ # - inc(*args)
650
+ # -->
651
+ # See self.inc
652
+ #
653
+ def inc: (*untyped args) -> untyped
654
+
655
+ # <!--
656
+ # rdoc-file=lib/optparse.rb
657
+ # - load(filename = nil, **keywords)
658
+ # -->
659
+ # Loads options from file names as `filename`. Does nothing when the file is not
660
+ # present. Returns whether successfully loaded.
661
+ #
662
+ # `filename` defaults to basename of the program without suffix in a directory
663
+ # ~/.options, then the basename with '.options' suffix under XDG and Haiku
664
+ # standard places.
665
+ #
666
+ # The optional `into` keyword argument works exactly like that accepted in
667
+ # method #parse.
668
+ #
669
+ def load: (?String filename) -> bool
670
+
671
+ # <!--
672
+ # rdoc-file=lib/optparse.rb
673
+ # - make_switch(params, block = nil)
674
+ # -->
675
+ # Creates an option from the given parameters `params`. See [Parameters for New
676
+ # Options](optparse/option_params.rdoc).
677
+ #
678
+ # The block, if given, is the handler for the created option. When the option is
679
+ # encountered during command-line parsing, the block is called with the argument
680
+ # given for the option, if any. See [Option
681
+ # Handlers](optparse/option_params.rdoc#label-Option+Handlers).
682
+ #
683
+ def make_switch: (Array[untyped] opts, ?Proc block) -> [ untyped, untyped, untyped, untyped, untyped ]
684
+
685
+ # <!--
686
+ # rdoc-file=lib/optparse.rb
687
+ # - new() { |self| ... }
688
+ # -->
689
+ # Pushes a new List.
690
+ #
691
+ # If a block is given, yields `self` and returns the result of the block,
692
+ # otherwise returns `self`.
693
+ #
694
+ def new: () -> self
695
+ | [T] () { (self) -> T } -> T
696
+
697
+ # <!--
698
+ # rdoc-file=lib/optparse.rb
699
+ # - on(*params, &block)
700
+ # -->
701
+ # Creates an option from the given parameters `params`. See [Parameters for New
702
+ # Options](optparse/option_params.rdoc).
703
+ #
704
+ # The block, if given, is the handler for the created option. When the option is
705
+ # encountered during command-line parsing, the block is called with the argument
706
+ # given for the option, if any. See [Option
707
+ # Handlers](optparse/option_params.rdoc#label-Option+Handlers).
708
+ #
709
+ def on: (*String params) ?{ (*untyped) -> untyped } -> self
710
+ | (String params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc) ?{ (*untyped) -> untyped } -> self
711
+ | (String short_params, String long_params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc) ?{ (*untyped) -> untyped } -> self
712
+ | (*String params, Proc | Method handler) -> self
713
+ | (String params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc, Proc | Method handler) -> self
714
+ | (String short_params, String long_params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc, Proc | Method handler) -> self
715
+
716
+ # <!--
717
+ # rdoc-file=lib/optparse.rb
718
+ # - on_head(*params, &block)
719
+ # -->
720
+ # Creates an option from the given parameters `params`. See [Parameters for New
721
+ # Options](optparse/option_params.rdoc).
722
+ #
723
+ # The block, if given, is the handler for the created option. When the option is
724
+ # encountered during command-line parsing, the block is called with the argument
725
+ # given for the option, if any. See [Option
726
+ # Handlers](optparse/option_params.rdoc#label-Option+Handlers).
727
+ #
728
+ # The new option is added at the head of the summary.
729
+ #
730
+ def on_head: (*String params) ?{ (*untyped) -> untyped } -> self
731
+ | (String params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc) ?{ (*untyped) -> untyped } -> self
732
+ | (String short_params, String long_params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc) ?{ (*untyped) -> untyped } -> self
733
+ | (*String params, Proc | Method handler) -> self
734
+ | (String params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc, Proc | Method handler) -> self
735
+ | (String short_params, String long_params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc, Proc | Method handler) -> self
736
+
737
+ # <!--
738
+ # rdoc-file=lib/optparse.rb
739
+ # - on_tail(*params, &block)
740
+ # -->
741
+ # Creates an option from the given parameters `params`. See [Parameters for New
742
+ # Options](optparse/option_params.rdoc).
743
+ #
744
+ # The block, if given, is the handler for the created option. When the option is
745
+ # encountered during command-line parsing, the block is called with the argument
746
+ # given for the option, if any. See [Option
747
+ # Handlers](optparse/option_params.rdoc#label-Option+Handlers).
748
+ #
749
+ # The new option is added at the tail of the summary.
750
+ #
751
+ def on_tail: (*String params) ?{ (*untyped) -> untyped } -> self
752
+ | (String params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc) ?{ (*untyped) -> untyped } -> self
753
+ | (String short_params, String long_params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc) ?{ (*untyped) -> untyped } -> self
754
+ | (*String params, Proc | Method handler) -> self
755
+ | (String params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc, Proc | Method handler) -> self
756
+ | (String short_params, String long_params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc, Proc | Method handler) -> self
757
+
758
+ # <!--
759
+ # rdoc-file=lib/optparse.rb
760
+ # - order(*argv, **keywords, &nonopt)
761
+ # -->
762
+ # Parses command line arguments `argv` in order. When a block is given, each
763
+ # non-option argument is yielded. When optional `into` keyword argument is
764
+ # provided, the parsed option values are stored there via <code>[]=</code>
765
+ # method (so it can be Hash, or OpenStruct, or other similar object).
766
+ #
767
+ # Returns the rest of `argv` left unparsed.
768
+ #
769
+ def order: (*String argv, ?into: _Intoable) ?{ (String) -> void } -> Array[String]
770
+ | (Array[String] argv, ?into: _Intoable) ?{ (String) -> void } -> Array[String]
771
+
772
+ # <!--
773
+ # rdoc-file=lib/optparse.rb
774
+ # - order!(argv = default_argv, into: nil, **keywords, &nonopt)
775
+ # -->
776
+ # Same as #order, but removes switches destructively. Non-option arguments
777
+ # remain in `argv`.
778
+ #
779
+ def order!: (?Array[String] argv, ?into: _Intoable) ?{ (String) -> void } -> Array[String]
780
+
781
+ # <!--
782
+ # rdoc-file=lib/optparse.rb
783
+ # - parse(*argv, **keywords)
784
+ # -->
785
+ # Parses command line arguments `argv` in order when environment variable
786
+ # POSIXLY_CORRECT is set, and in permutation mode otherwise. When optional
787
+ # `into` keyword argument is provided, the parsed option values are stored there
788
+ # via <code>[]=</code> method (so it can be Hash, or OpenStruct, or other
789
+ # similar object).
790
+ #
791
+ def parse: (*String argv, ?into: _Intoable) -> Array[String]
792
+ | (Array[String] argv, ?into: _Intoable) -> Array[String]
793
+
794
+ # <!--
795
+ # rdoc-file=lib/optparse.rb
796
+ # - parse!(argv = default_argv, **keywords)
797
+ # -->
798
+ # Same as #parse, but removes switches destructively. Non-option arguments
799
+ # remain in `argv`.
800
+ #
801
+ def parse!: (?Array[String] argv, ?into: _Intoable) -> Array[String]
802
+
803
+ # <!--
804
+ # rdoc-file=lib/optparse.rb
805
+ # - permute(*argv, **keywords)
806
+ # -->
807
+ # Parses command line arguments `argv` in permutation mode and returns list of
808
+ # non-option arguments. When optional `into` keyword argument is provided, the
809
+ # parsed option values are stored there via <code>[]=</code> method (so it can
810
+ # be Hash, or OpenStruct, or other similar object).
811
+ #
812
+ def permute: (*String argv, ?into: _Intoable) -> Array[String]
813
+ | (Array[String] argv, ?into: _Intoable) -> Array[String]
814
+
815
+ # <!--
816
+ # rdoc-file=lib/optparse.rb
817
+ # - permute!(argv = default_argv, **keywords)
818
+ # -->
819
+ # Same as #permute, but removes switches destructively. Non-option arguments
820
+ # remain in `argv`.
821
+ #
822
+ def permute!: (?Array[String] argv, ?into: _Intoable) -> Array[String]
823
+
824
+ # <!-- rdoc-file=lib/optparse.rb -->
825
+ # Program name to be emitted in error message and default banner, defaults to
826
+ # $0.
827
+ #
828
+ attr_accessor program_name: String
829
+
830
+ # <!-- rdoc-file=lib/optparse.rb -->
831
+ # Whether to raise at unknown option.
832
+ #
833
+ attr_accessor raise_unknown: boolish
834
+
835
+ # <!--
836
+ # rdoc-file=lib/optparse.rb
837
+ # - reject(*args, &blk)
838
+ # -->
839
+ # Directs to reject specified class argument.
840
+ #
841
+ # `type`
842
+ # : Argument class specifier, any object including Class.
843
+ #
844
+ #
845
+ # reject(type)
846
+ #
847
+ def reject: (Class t) -> void
848
+
849
+ # <!-- rdoc-file=lib/optparse.rb -->
850
+ # Release code
851
+ #
852
+ def release: () -> untyped
853
+
854
+ # <!-- rdoc-file=lib/optparse.rb -->
855
+ # Release code
856
+ #
857
+ def release=: (untyped) -> untyped
858
+
859
+ # <!--
860
+ # rdoc-file=lib/optparse.rb
861
+ # - remove()
862
+ # -->
863
+ # Removes the last List.
864
+ #
865
+ def remove: () -> List?
866
+
867
+ # <!-- rdoc-file=lib/optparse.rb -->
868
+ # Whether to require that options match exactly (disallows providing abbreviated
869
+ # long option as short option).
870
+ #
871
+ attr_accessor require_exact: boolish
872
+
873
+ # <!--
874
+ # rdoc-file=lib/optparse.rb
875
+ # - separator(string)
876
+ # -->
877
+ # Add separator in summary.
878
+ #
879
+ def separator: (String string) -> void
880
+
881
+ # <!-- rdoc-file=lib/optparse.rb -->
882
+ # Heading banner preceding summary.
883
+ #
884
+ alias set_banner banner=
885
+
886
+ # <!-- rdoc-file=lib/optparse.rb -->
887
+ # Program name to be emitted in error message and default banner, defaults to
888
+ # $0.
889
+ #
890
+ alias set_program_name program_name=
891
+
892
+ # <!-- rdoc-file=lib/optparse.rb -->
893
+ # Indentation for summary. Must be String (or have + String method).
894
+ #
895
+ alias set_summary_indent summary_indent=
896
+
897
+ # <!-- rdoc-file=lib/optparse.rb -->
898
+ # Width for option list portion of summary. Must be Numeric.
899
+ #
900
+ alias set_summary_width summary_width=
901
+
902
+ # <!--
903
+ # rdoc-file=lib/optparse.rb
904
+ # - summarize(to = [], width = @summary_width, max = width - 1, indent = @summary_indent, &blk)
905
+ # -->
906
+ # Puts option summary into `to` and returns `to`. Yields each line if a block is
907
+ # given.
908
+ #
909
+ # `to`
910
+ # : Output destination, which must have method <<. Defaults to [].
911
+ #
912
+ # `width`
913
+ # : Width of left side, defaults to @summary_width.
914
+ #
915
+ # `max`
916
+ # : Maximum length allowed for left side, defaults to `width` - 1.
917
+ #
918
+ # `indent`
919
+ # : Indentation, defaults to @summary_indent.
920
+ #
921
+ def summarize: (?_LtLtString to, ?Integer width, ?Integer max, ?String indent) ?{ (String line) -> void } -> _LtLtString
922
+
923
+ # <!-- rdoc-file=lib/optparse.rb -->
924
+ # Indentation for summary. Must be String (or have + String method).
925
+ #
926
+ attr_accessor summary_indent: String
927
+
928
+ # <!-- rdoc-file=lib/optparse.rb -->
929
+ # Width for option list portion of summary. Must be Numeric.
930
+ #
931
+ attr_accessor summary_width: Integer
932
+
933
+ # <!--
934
+ # rdoc-file=lib/optparse.rb
935
+ # - terminate(arg = nil)
936
+ # -->
937
+ # Terminates option parsing. Optional parameter `arg` is a string pushed back to
938
+ # be the first non-option argument.
939
+ #
940
+ def terminate: (?String arg) -> bot
941
+
942
+ # <!--
943
+ # rdoc-file=lib/optparse.rb
944
+ # - to_a()
945
+ # -->
946
+ # Returns option summary list.
947
+ #
948
+ def to_a: () -> Array[String]
949
+
950
+ # <!--
951
+ # rdoc-file=lib/optparse.rb
952
+ # - to_s()
953
+ # -->
954
+ #
955
+ alias to_s help
956
+
957
+ # <!--
958
+ # rdoc-file=lib/optparse.rb
959
+ # - top()
960
+ # -->
961
+ # Subject of #on / #on_head, #accept / #reject
962
+ #
963
+ def top: () -> List
964
+
965
+ # <!--
966
+ # rdoc-file=lib/optparse.rb
967
+ # - ver()
968
+ # -->
969
+ # Returns version string from program_name, version and release.
970
+ #
971
+ def ver: () -> String?
972
+
973
+ # <!-- rdoc-file=lib/optparse.rb -->
974
+ # Version
975
+ #
976
+ attr_accessor version: String?
977
+
978
+ # <!--
979
+ # rdoc-file=lib/optparse.rb
980
+ # - warn(mesg = $!)
981
+ # -->
982
+ # Shows warning message with the program name
983
+ #
984
+ # `mesg`
985
+ # : Message, defaulted to +$!+.
986
+ #
987
+ #
988
+ # See Kernel#warn.
989
+ #
990
+ def warn: (?_ToS mesg) -> void
991
+
992
+ private
993
+
994
+ # <!--
995
+ # rdoc-file=lib/optparse.rb
996
+ # - complete(typ, opt, icase = false, *pat)
997
+ # -->
998
+ # Completes shortened long style option switch and returns pair of canonical
999
+ # switch and switch descriptor OptionParser::Switch.
1000
+ #
1001
+ # `typ`
1002
+ # : Searching table.
1003
+ # `opt`
1004
+ # : Searching key.
1005
+ # `icase`
1006
+ # : Search case insensitive if true.
1007
+ # `pat`
1008
+ # : Optional pattern for completion.
1009
+ #
1010
+ def complete: (untyped typ, untyped opt, ?untyped icase, *untyped pat) -> untyped
1011
+
1012
+ # <!--
1013
+ # rdoc-file=lib/optparse.rb
1014
+ # - new(banner = nil, width = 32, indent = ' ' * 4) { |self| ... }
1015
+ # -->
1016
+ # Initializes the instance and yields itself if called with a block.
1017
+ #
1018
+ # `banner`
1019
+ # : Banner message.
1020
+ #
1021
+ # `width`
1022
+ # : Summary width.
1023
+ #
1024
+ # `indent`
1025
+ # : Summary indent.
1026
+ #
1027
+ def initialize: (?String banner, ?Integer width, ?String indent) ?{ (OptionParser) -> void } -> void
1028
+
1029
+ # <!--
1030
+ # rdoc-file=lib/optparse.rb
1031
+ # - notwice(obj, prv, msg)
1032
+ # -->
1033
+ # Checks if an argument is given twice, in which case an ArgumentError is
1034
+ # raised. Called from OptionParser#switch only.
1035
+ #
1036
+ # `obj`
1037
+ # : New argument.
1038
+ # `prv`
1039
+ # : Previously specified argument.
1040
+ # `msg`
1041
+ # : Exception message.
1042
+ #
1043
+ def notwice: (untyped obj, untyped prv, untyped msg) -> untyped
1044
+
1045
+ def parse_in_order: (?untyped argv, ?untyped setter) { (*untyped) -> untyped } -> untyped
1046
+
1047
+ # <!--
1048
+ # rdoc-file=lib/optparse.rb
1049
+ # - search(id, key) { |k| ... }
1050
+ # -->
1051
+ # Searches `key` in @stack for `id` hash and returns or yields the result.
1052
+ #
1053
+ def search: (untyped id, untyped key) -> untyped
1054
+
1055
+ # <!--
1056
+ # rdoc-file=lib/optparse.rb
1057
+ # - visit(id, *args, &block)
1058
+ # -->
1059
+ # Traverses @stack, sending each element method `id` with `args` and `block`.
1060
+ #
1061
+ def visit: (untyped id, *untyped args) { (*untyped) -> untyped } -> untyped
1062
+ end
1063
+
1064
+ OptionParser::ArgumentStyle: Hash[untyped, untyped]
1065
+
1066
+ OptionParser::COMPSYS_HEADER: String
1067
+
1068
+ # <!-- rdoc-file=lib/optparse.rb -->
1069
+ # Decimal integer format, to be converted to Integer.
1070
+ #
1071
+ OptionParser::DecimalInteger: Regexp
1072
+
1073
+ # <!-- rdoc-file=lib/optparse.rb -->
1074
+ # Decimal integer/float number format, to be converted to Integer for integer
1075
+ # format, Float for float format.
1076
+ #
1077
+ OptionParser::DecimalNumeric: Regexp
1078
+
1079
+ OptionParser::DefaultList: OptionParser::List
1080
+
1081
+ OptionParser::NO_ARGUMENT: Symbol
1082
+
1083
+ OptionParser::NoArgument: [ :NONE, nil ]
1084
+
1085
+ OptionParser::OPTIONAL_ARGUMENT: Symbol
1086
+
1087
+ # <!-- rdoc-file=lib/optparse.rb -->
1088
+ # Ruby/C like octal/hexadecimal/binary integer format, to be converted to
1089
+ # Integer.
1090
+ #
1091
+ OptionParser::OctalInteger: Regexp
1092
+
1093
+ OptionParser::Officious: Hash[untyped, untyped]
1094
+
1095
+ OptionParser::OptionalArgument: Array[untyped]
1096
+
1097
+ OptionParser::REQUIRED_ARGUMENT: Symbol
1098
+
1099
+ OptionParser::RequiredArgument: Array[untyped]
1100
+
1101
+ OptionParser::SPLAT_PROC: Proc
1102
+
1103
+ # <!-- rdoc-file=lib/optparse.rb -->
1104
+ # An alias for compatibility
1105
+ #
1106
+ OptionParser::Version: String
1107
+
1108
+ # <!-- rdoc-file=lib/optparse.rb -->
1109
+ # Acceptable argument classes. Now contains DecimalInteger, OctalInteger and
1110
+ # DecimalNumeric. See Acceptable argument classes (in source code).
1111
+ #
1112
+ module OptionParser::Acceptables
1113
+ end
1114
+
1115
+ OptionParser::Acceptables::DecimalInteger: Regexp
1116
+
1117
+ OptionParser::Acceptables::DecimalNumeric: Regexp
1118
+
1119
+ OptionParser::Acceptables::OctalInteger: Regexp
1120
+
1121
+ # <!-- rdoc-file=lib/optparse.rb -->
1122
+ # Raises when the given argument word can't be completed uniquely.
1123
+ #
1124
+ class OptionParser::AmbiguousArgument < OptionParser::InvalidArgument
1125
+ end
1126
+
1127
+ OptionParser::AmbiguousArgument::Reason: String
1128
+
1129
+ # <!-- rdoc-file=lib/optparse.rb -->
1130
+ # Raises when ambiguously completable string is encountered.
1131
+ #
1132
+ class OptionParser::AmbiguousOption < OptionParser::ParseError
1133
+ end
1134
+
1135
+ OptionParser::AmbiguousOption::Reason: String
1136
+
1137
+ # <!-- rdoc-file=lib/optparse.rb -->
1138
+ # Extends command line arguments array (ARGV) to parse itself.
1139
+ #
1140
+ module OptionParser::Arguable
1141
+ # <!--
1142
+ # rdoc-file=lib/optparse.rb
1143
+ # - extend_object(obj)
1144
+ # -->
1145
+ # Initializes instance variable.
1146
+ #
1147
+ def self.extend_object: (untyped obj) -> untyped
1148
+
1149
+ # <!--
1150
+ # rdoc-file=lib/optparse.rb
1151
+ # - getopts(*args, symbolize_names: false, **keywords)
1152
+ # -->
1153
+ # Substitution of getopts is possible as follows. Also see OptionParser#getopts.
1154
+ #
1155
+ # def getopts(*args)
1156
+ # ($OPT = ARGV.getopts(*args)).each do |opt, val|
1157
+ # eval "$OPT_#{opt.gsub(/[^A-Za-z0-9_]/, '_')} = val"
1158
+ # end
1159
+ # rescue OptionParser::ParseError
1160
+ # end
1161
+ #
1162
+ def getopts: (*String args) -> Hash[String, untyped]
1163
+
1164
+ # <!--
1165
+ # rdoc-file=lib/optparse.rb
1166
+ # - options() { |optparse| ... }
1167
+ # -->
1168
+ # Actual OptionParser object, automatically created if nonexistent.
1169
+ #
1170
+ # If called with a block, yields the OptionParser object and returns the result
1171
+ # of the block. If an OptionParser::ParseError exception occurs in the block, it
1172
+ # is rescued, a error message printed to STDERR and `nil` returned.
1173
+ #
1174
+ def options: () -> OptionParser
1175
+ | [T] () { (OptionParser) -> T } -> T?
1176
+
1177
+ # <!--
1178
+ # rdoc-file=lib/optparse.rb
1179
+ # - options=(opt)
1180
+ # -->
1181
+ # Sets OptionParser object, when `opt` is `false` or `nil`, methods
1182
+ # OptionParser::Arguable#options and OptionParser::Arguable#options= are
1183
+ # undefined. Thus, there is no ways to access the OptionParser object via the
1184
+ # receiver object.
1185
+ #
1186
+ def options=: (OptionParser? opt) -> untyped
1187
+
1188
+ # <!--
1189
+ # rdoc-file=lib/optparse.rb
1190
+ # - order!(**keywords, &blk)
1191
+ # -->
1192
+ # Parses `self` destructively in order and returns `self` containing the rest
1193
+ # arguments left unparsed.
1194
+ #
1195
+ def order!: () ?{ (String) -> void } -> Array[String]
1196
+
1197
+ # <!--
1198
+ # rdoc-file=lib/optparse.rb
1199
+ # - parse!(**keywords)
1200
+ # -->
1201
+ # Parses `self` destructively and returns `self` containing the rest arguments
1202
+ # left unparsed.
1203
+ #
1204
+ def parse!: () -> Array[String]
1205
+
1206
+ # <!--
1207
+ # rdoc-file=lib/optparse.rb
1208
+ # - permute!(**keywords)
1209
+ # -->
1210
+ # Parses `self` destructively in permutation mode and returns `self` containing
1211
+ # the rest arguments left unparsed.
1212
+ #
1213
+ def permute!: () -> Array[String]
1214
+ end
1215
+
1216
+ # <!-- rdoc-file=lib/optparse.rb -->
1217
+ # Hash with completion search feature. See OptionParser::Completion.
1218
+ #
1219
+ class OptionParser::CompletingHash < Hash[untyped, untyped]
1220
+ include OptionParser::Completion
1221
+
1222
+ # <!--
1223
+ # rdoc-file=lib/optparse.rb
1224
+ # - match(key)
1225
+ # -->
1226
+ # Completion for hash key.
1227
+ #
1228
+ def match: (untyped key) -> untyped
1229
+ end
1230
+
1231
+ # <!-- rdoc-file=lib/optparse.rb -->
1232
+ # Keyword completion module. This allows partial arguments to be specified and
1233
+ # resolved against a list of acceptable values.
1234
+ #
1235
+ module OptionParser::Completion
1236
+ # <!--
1237
+ # rdoc-file=lib/optparse.rb
1238
+ # - candidate(key, icase = false, pat = nil, &block)
1239
+ # -->
1240
+ #
1241
+ def self.candidate: (untyped key, ?untyped icase, ?untyped pat) { (*untyped) -> untyped } -> untyped
1242
+
1243
+ # <!--
1244
+ # rdoc-file=lib/optparse.rb
1245
+ # - regexp(key, icase)
1246
+ # -->
1247
+ #
1248
+ def self.regexp: (untyped key, untyped icase) -> untyped
1249
+
1250
+ # <!--
1251
+ # rdoc-file=lib/optparse.rb
1252
+ # - candidate(key, icase = false, pat = nil)
1253
+ # -->
1254
+ #
1255
+ def candidate: (untyped key, ?untyped icase, ?untyped pat) -> untyped
1256
+
1257
+ # <!--
1258
+ # rdoc-file=lib/optparse.rb
1259
+ # - complete(key, icase = false, pat = nil) { |key, *sw| ... }
1260
+ # -->
1261
+ #
1262
+ def complete: (untyped key, ?untyped icase, ?untyped pat) -> untyped
1263
+
1264
+ # <!--
1265
+ # rdoc-file=lib/optparse.rb
1266
+ # - convert(opt = nil, val = nil, *)
1267
+ # -->
1268
+ #
1269
+ def convert: (?untyped opt, ?untyped val, *untyped) -> untyped
1270
+ end
1271
+
1272
+ # <!-- rdoc-file=lib/optparse.rb -->
1273
+ # Raises when the given argument does not match required format.
1274
+ #
1275
+ class OptionParser::InvalidArgument < OptionParser::ParseError
1276
+ end
1277
+
1278
+ OptionParser::InvalidArgument::Reason: String
1279
+
1280
+ # <!-- rdoc-file=lib/optparse.rb -->
1281
+ # Raises when switch is undefined.
1282
+ #
1283
+ class OptionParser::InvalidOption < OptionParser::ParseError
1284
+ end
1285
+
1286
+ OptionParser::InvalidOption::Reason: String
1287
+
1288
+ # <!-- rdoc-file=lib/optparse.rb -->
1289
+ # Simple option list providing mapping from short and/or long option string to
1290
+ # OptionParser::Switch and mapping from acceptable argument to matching pattern
1291
+ # and converter pair. Also provides summary feature.
1292
+ #
1293
+ class OptionParser::List
1294
+ # <!--
1295
+ # rdoc-file=lib/optparse.rb
1296
+ # - accept(t, pat = /.*/m, &block)
1297
+ # -->
1298
+ # See OptionParser.accept.
1299
+ #
1300
+ def accept: (untyped t, ?untyped pat) { (*untyped) -> untyped } -> untyped
1301
+
1302
+ def add_banner: (untyped to) -> untyped
1303
+
1304
+ # <!--
1305
+ # rdoc-file=lib/optparse.rb
1306
+ # - append(*args)
1307
+ # -->
1308
+ # Appends `switch` at the tail of the list, and associates short, long and
1309
+ # negated long options. Arguments are:
1310
+ #
1311
+ # `switch`
1312
+ # : OptionParser::Switch instance to be inserted.
1313
+ #
1314
+ # `short_opts`
1315
+ # : List of short style options.
1316
+ #
1317
+ # `long_opts`
1318
+ # : List of long style options.
1319
+ #
1320
+ # `nolong_opts`
1321
+ # : List of long style options with "no-" prefix.
1322
+ #
1323
+ #
1324
+ # append(switch, short_opts, long_opts, nolong_opts)
1325
+ #
1326
+ def append: (*untyped args) -> untyped
1327
+
1328
+ # <!-- rdoc-file=lib/optparse.rb -->
1329
+ # Map from acceptable argument types to pattern and converter pairs.
1330
+ #
1331
+ def atype: () -> untyped
1332
+
1333
+ # <!--
1334
+ # rdoc-file=lib/optparse.rb
1335
+ # - complete(id, opt, icase = false, *pat, &block)
1336
+ # -->
1337
+ # Searches list `id` for `opt` and the optional patterns for completion `pat`.
1338
+ # If `icase` is true, the search is case insensitive. The result is returned or
1339
+ # yielded if a block is given. If it isn't found, nil is returned.
1340
+ #
1341
+ def complete: (untyped id, untyped opt, ?untyped icase, *untyped pat) { (*untyped) -> untyped } -> untyped
1342
+
1343
+ def compsys: (*untyped args) { (*untyped) -> untyped } -> untyped
1344
+
1345
+ # <!--
1346
+ # rdoc-file=lib/optparse.rb
1347
+ # - each_option(&block)
1348
+ # -->
1349
+ # Iterates over each option, passing the option to the `block`.
1350
+ #
1351
+ def each_option: () { (*untyped) -> untyped } -> untyped
1352
+
1353
+ # <!--
1354
+ # rdoc-file=lib/optparse.rb
1355
+ # - get_candidates(id) { |__send__(id).keys| ... }
1356
+ # -->
1357
+ #
1358
+ def get_candidates: (untyped id) -> untyped
1359
+
1360
+ # <!-- rdoc-file=lib/optparse.rb -->
1361
+ # List of all switches and summary string.
1362
+ #
1363
+ def list: () -> untyped
1364
+
1365
+ # <!-- rdoc-file=lib/optparse.rb -->
1366
+ # Map from long style option switches to actual switch objects.
1367
+ #
1368
+ def long: () -> untyped
1369
+
1370
+ # <!--
1371
+ # rdoc-file=lib/optparse.rb
1372
+ # - prepend(*args)
1373
+ # -->
1374
+ # Inserts `switch` at the head of the list, and associates short, long and
1375
+ # negated long options. Arguments are:
1376
+ #
1377
+ # `switch`
1378
+ # : OptionParser::Switch instance to be inserted.
1379
+ #
1380
+ # `short_opts`
1381
+ # : List of short style options.
1382
+ #
1383
+ # `long_opts`
1384
+ # : List of long style options.
1385
+ #
1386
+ # `nolong_opts`
1387
+ # : List of long style options with "no-" prefix.
1388
+ #
1389
+ #
1390
+ # prepend(switch, short_opts, long_opts, nolong_opts)
1391
+ #
1392
+ def prepend: (*untyped args) -> untyped
1393
+
1394
+ # <!--
1395
+ # rdoc-file=lib/optparse.rb
1396
+ # - reject(t)
1397
+ # -->
1398
+ # See OptionParser.reject.
1399
+ #
1400
+ def reject: (untyped t) -> untyped
1401
+
1402
+ # <!--
1403
+ # rdoc-file=lib/optparse.rb
1404
+ # - search(id, key) { |val| ... }
1405
+ # -->
1406
+ # Searches `key` in `id` list. The result is returned or yielded if a block is
1407
+ # given. If it isn't found, nil is returned.
1408
+ #
1409
+ def search: (untyped id, untyped key) -> untyped
1410
+
1411
+ # <!-- rdoc-file=lib/optparse.rb -->
1412
+ # Map from short style option switches to actual switch objects.
1413
+ #
1414
+ def short: () -> untyped
1415
+
1416
+ # <!--
1417
+ # rdoc-file=lib/optparse.rb
1418
+ # - summarize(*args, &block)
1419
+ # -->
1420
+ # Creates the summary table, passing each line to the `block` (without newline).
1421
+ # The arguments `args` are passed along to the summarize method which is called
1422
+ # on every option.
1423
+ #
1424
+ def summarize: (*untyped args) { (*untyped) -> untyped } -> untyped
1425
+
1426
+ private
1427
+
1428
+ # <!--
1429
+ # rdoc-file=lib/optparse.rb
1430
+ # - new()
1431
+ # -->
1432
+ # Just initializes all instance variables.
1433
+ #
1434
+ def initialize: () -> void
1435
+
1436
+ # <!--
1437
+ # rdoc-file=lib/optparse.rb
1438
+ # - update(sw, sopts, lopts, nsw = nil, nlopts = nil)
1439
+ # -->
1440
+ # Adds `sw` according to `sopts`, `lopts` and `nlopts`.
1441
+ #
1442
+ # `sw`
1443
+ # : OptionParser::Switch instance to be added.
1444
+ # `sopts`
1445
+ # : Short style option list.
1446
+ # `lopts`
1447
+ # : Long style option list.
1448
+ # `nlopts`
1449
+ # : Negated long style options list.
1450
+ #
1451
+ def update: (untyped sw, untyped sopts, untyped lopts, ?untyped nsw, ?untyped nlopts) -> untyped
1452
+ end
1453
+
1454
+ # <!-- rdoc-file=lib/optparse.rb -->
1455
+ # Raises when a switch with mandatory argument has no argument.
1456
+ #
1457
+ class OptionParser::MissingArgument < OptionParser::ParseError
1458
+ end
1459
+
1460
+ OptionParser::MissingArgument::Reason: String
1461
+
1462
+ # <!-- rdoc-file=lib/optparse.rb -->
1463
+ # Raises when there is an argument for a switch which takes no argument.
1464
+ #
1465
+ class OptionParser::NeedlessArgument < OptionParser::ParseError
1466
+ end
1467
+
1468
+ OptionParser::NeedlessArgument::Reason: String
1469
+
1470
+ # <!-- rdoc-file=lib/optparse.rb -->
1471
+ # Map from option/keyword string to object with completion.
1472
+ #
1473
+ class OptionParser::OptionMap < Hash[untyped, untyped]
1474
+ include OptionParser::Completion
1475
+ end
1476
+
1477
+ # <!-- rdoc-file=lib/optparse.rb -->
1478
+ # Base class of exceptions from OptionParser.
1479
+ #
1480
+ class OptionParser::ParseError < RuntimeError
1481
+ # <!--
1482
+ # rdoc-file=lib/optparse.rb
1483
+ # - filter_backtrace(array)
1484
+ # -->
1485
+ #
1486
+ def self.filter_backtrace: (untyped array) -> untyped
1487
+
1488
+ def additional: () -> untyped
1489
+
1490
+ def additional=: (untyped) -> untyped
1491
+
1492
+ def args: () -> untyped
1493
+
1494
+ # <!--
1495
+ # rdoc-file=lib/optparse.rb
1496
+ # - inspect()
1497
+ # -->
1498
+ #
1499
+ def inspect: () -> untyped
1500
+
1501
+ # <!--
1502
+ # rdoc-file=lib/optparse.rb
1503
+ # - message()
1504
+ # -->
1505
+ # Default stringizing method to emit standard error message.
1506
+ #
1507
+ def message: () -> String
1508
+
1509
+ # <!-- rdoc-file=lib/optparse.rb -->
1510
+ #
1511
+ def reason: () -> untyped
1512
+
1513
+ def reason=: (untyped) -> untyped
1514
+
1515
+ # <!--
1516
+ # rdoc-file=lib/optparse.rb
1517
+ # - recover(argv)
1518
+ # -->
1519
+ # Pushes back erred argument(s) to `argv`.
1520
+ #
1521
+ def recover: (untyped argv) -> untyped
1522
+
1523
+ # <!--
1524
+ # rdoc-file=lib/optparse.rb
1525
+ # - set_backtrace(array)
1526
+ # -->
1527
+ #
1528
+ def set_backtrace: (untyped array) -> untyped
1529
+
1530
+ # <!--
1531
+ # rdoc-file=lib/optparse.rb
1532
+ # - set_option(opt, eq)
1533
+ # -->
1534
+ #
1535
+ def set_option: (untyped opt, untyped eq) -> untyped
1536
+
1537
+ # <!--
1538
+ # rdoc-file=lib/optparse.rb
1539
+ # - to_s()
1540
+ # -->
1541
+ #
1542
+ alias to_s message
1543
+
1544
+ private
1545
+
1546
+ # <!--
1547
+ # rdoc-file=lib/optparse.rb
1548
+ # - new(*args, additional: nil)
1549
+ # -->
1550
+ #
1551
+ def initialize: (*untyped args, ?additional: untyped) -> void
1552
+ end
1553
+
1554
+ # <!-- rdoc-file=lib/optparse.rb -->
1555
+ # Reason which caused the error.
1556
+ #
1557
+ OptionParser::ParseError::Reason: String
1558
+
1559
+ # <!-- rdoc-file=lib/optparse.rb -->
1560
+ # Individual switch class. Not important to the user.
1561
+ #
1562
+ # Defined within Switch are several Switch-derived classes: NoArgument,
1563
+ # RequiredArgument, etc.
1564
+ #
1565
+ class OptionParser::Switch
1566
+ # <!--
1567
+ # rdoc-file=lib/optparse.rb
1568
+ # - guess(arg)
1569
+ # -->
1570
+ # Guesses argument style from `arg`. Returns corresponding OptionParser::Switch
1571
+ # class (OptionalArgument, etc.).
1572
+ #
1573
+ def self.guess: (untyped arg) -> untyped
1574
+
1575
+ # <!--
1576
+ # rdoc-file=lib/optparse.rb
1577
+ # - incompatible_argument_styles(arg, t)
1578
+ # -->
1579
+ #
1580
+ def self.incompatible_argument_styles: (untyped arg, untyped t) -> untyped
1581
+
1582
+ # <!--
1583
+ # rdoc-file=lib/optparse.rb
1584
+ # - pattern()
1585
+ # -->
1586
+ #
1587
+ def self.pattern: () -> untyped
1588
+
1589
+ def add_banner: (untyped to) -> untyped
1590
+
1591
+ def arg: () -> untyped
1592
+
1593
+ def block: () -> untyped
1594
+
1595
+ def compsys: (untyped sdone, untyped ldone) -> untyped
1596
+
1597
+ def conv: () -> untyped
1598
+
1599
+ def desc: () -> untyped
1600
+
1601
+ def long: () -> untyped
1602
+
1603
+ def match_nonswitch?: (untyped str) -> untyped
1604
+
1605
+ def pattern: () -> untyped
1606
+
1607
+ def short: () -> untyped
1608
+
1609
+ # <!--
1610
+ # rdoc-file=lib/optparse.rb
1611
+ # - summarize(sdone = {}, ldone = {}, width = 1, max = width - 1, indent = "") { |indent| ... }
1612
+ # -->
1613
+ # Produces the summary text. Each line of the summary is yielded to the block
1614
+ # (without newline).
1615
+ #
1616
+ # `sdone`
1617
+ # : Already summarized short style options keyed hash.
1618
+ #
1619
+ # `ldone`
1620
+ # : Already summarized long style options keyed hash.
1621
+ #
1622
+ # `width`
1623
+ # : Width of left side (option part). In other words, the right side
1624
+ # (description part) starts after `width` columns.
1625
+ #
1626
+ # `max`
1627
+ # : Maximum width of left side -> the options are filled within `max` columns.
1628
+ #
1629
+ # `indent`
1630
+ # : Prefix string indents all summarized lines.
1631
+ #
1632
+ def summarize: (?untyped sdone, ?untyped ldone, ?untyped width, ?untyped max, ?untyped indent) -> untyped
1633
+
1634
+ # <!--
1635
+ # rdoc-file=lib/optparse.rb
1636
+ # - switch_name()
1637
+ # -->
1638
+ # Main name of the switch.
1639
+ #
1640
+ def switch_name: () -> untyped
1641
+
1642
+ private
1643
+
1644
+ # <!--
1645
+ # rdoc-file=lib/optparse.rb
1646
+ # - conv_arg(arg, val = [])
1647
+ # -->
1648
+ # Parses argument, converts and returns `arg`, `block` and result of conversion.
1649
+ # Yields at semi-error condition instead of raising an exception.
1650
+ #
1651
+ def conv_arg: (untyped arg, ?untyped val) -> untyped
1652
+
1653
+ # <!--
1654
+ # rdoc-file=lib/optparse.rb
1655
+ # - new(pattern = nil, conv = nil, short = nil, long = nil, arg = nil, desc = ([] if short or long), block = nil, &_block)
1656
+ # -->
1657
+ #
1658
+ def initialize: (?untyped pattern, ?untyped conv, ?untyped short, ?untyped long, ?untyped arg, ?untyped desc, ?untyped block) { (*untyped) -> untyped } -> void
1659
+
1660
+ # <!--
1661
+ # rdoc-file=lib/optparse.rb
1662
+ # - parse_arg(arg) { |InvalidArgument, arg| ... }
1663
+ # -->
1664
+ # Parses `arg` and returns rest of `arg` and matched portion to the argument
1665
+ # pattern. Yields when the pattern doesn't match substring.
1666
+ #
1667
+ def parse_arg: (untyped arg) -> untyped
1668
+ end
1669
+
1670
+ # <!-- rdoc-file=lib/optparse.rb -->
1671
+ # Switch that takes no arguments.
1672
+ #
1673
+ class OptionParser::Switch::NoArgument < OptionParser::Switch
1674
+ # <!--
1675
+ # rdoc-file=lib/optparse.rb
1676
+ # - incompatible_argument_styles(*)
1677
+ # -->
1678
+ #
1679
+ def self.incompatible_argument_styles: (*untyped) -> untyped
1680
+
1681
+ # <!--
1682
+ # rdoc-file=lib/optparse.rb
1683
+ # - pattern()
1684
+ # -->
1685
+ #
1686
+ def self.pattern: () -> untyped
1687
+
1688
+ # <!--
1689
+ # rdoc-file=lib/optparse.rb
1690
+ # - parse(arg, argv) { |NeedlessArgument, arg| ... }
1691
+ # -->
1692
+ # Raises an exception if any arguments given.
1693
+ #
1694
+ def parse: (untyped arg, untyped argv) -> untyped
1695
+ end
1696
+
1697
+ # <!-- rdoc-file=lib/optparse.rb -->
1698
+ # Switch that can omit argument.
1699
+ #
1700
+ class OptionParser::Switch::OptionalArgument < OptionParser::Switch
1701
+ # <!--
1702
+ # rdoc-file=lib/optparse.rb
1703
+ # - parse(arg, argv, &error)
1704
+ # -->
1705
+ # Parses argument if given, or uses default value.
1706
+ #
1707
+ def parse: (untyped arg, untyped argv) { (*untyped) -> untyped } -> untyped
1708
+ end
1709
+
1710
+ # <!-- rdoc-file=lib/optparse.rb -->
1711
+ # Switch that takes an argument, which does not begin with '-' or is '-'.
1712
+ #
1713
+ class OptionParser::Switch::PlacedArgument < OptionParser::Switch
1714
+ # <!--
1715
+ # rdoc-file=lib/optparse.rb
1716
+ # - parse(arg, argv, &error)
1717
+ # -->
1718
+ # Returns nil if argument is not present or begins with '-' and is not '-'.
1719
+ #
1720
+ def parse: (untyped arg, untyped argv) { (*untyped) -> untyped } -> untyped
1721
+ end
1722
+
1723
+ # <!-- rdoc-file=lib/optparse.rb -->
1724
+ # Switch that takes an argument.
1725
+ #
1726
+ class OptionParser::Switch::RequiredArgument < OptionParser::Switch
1727
+ # <!--
1728
+ # rdoc-file=lib/optparse.rb
1729
+ # - parse(arg, argv, &_)
1730
+ # -->
1731
+ # Raises an exception if argument is not present.
1732
+ #
1733
+ def parse: (untyped arg, untyped argv) -> untyped
1734
+ end