42件ヒット
[1-42件を表示]
(0.145秒)
種類
- インスタンスメソッド (22)
- ライブラリ (11)
- 文書 (9)
ライブラリ
- optparse (22)
クラス
- OptionParser (11)
モジュール
キーワード
-
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) - getopts (11)
-
on
_ tail (11)
検索結果
先頭5件
-
optparse (38324.0)
-
コマンドラインのオプションを取り扱うためのライブラリです。
...コマンドラインのオプションを取り扱うためのライブラリです。
=== チュートリアル
optparse を使う場合、基本的には
(1) OptionParser オブジェクト opt を生成する。
(2) オプションを取り扱うブロックを opt に登録する。
(3) o......す。
* optiondef
* optionarg
* longoption
* help
* subcmd
* argv
* hyphen_start_file
====[a:optiondef] オプションの定義
以下はオプション -a, -b を受け付けるコマンドを作成する例です。
//emlist[sample.rb][ruby]{
require 'optparse'
opt = OptionParser.new......。
====[a:help] ヘルプ
デフォルトで --help と --version オプションを認識します。
ruby ./sample.rb --help
# => Usage: sample [options]
ruby ./sample.rb --version
# => *出力なし*
--version は、トップレベルに Version 定数が定... -
OptionParser
# on _ tail(*arg , &block) -> self (14166.0) -
オプションを取り扱うためのブロックを自身の持つリストの最後に登録します。
...--version や --help の説明をサマリの最後に表示したい時に便利です。
@param arg OptionParser#on と同様です。
@param block OptionParser#on と同様です。
//emlist[例][ruby]{
require "optparse"
opts = OptionParser.new do |opts|
opts.on_head("-i", "--init")
op......n_tail("-h", "--help")
end
puts opts.help
# => Usage: test [options]
# -i, --init
# -u, --update
# -h, --help
//}
//emlist[例][ruby]{
require "optparse"
opts = OptionParser.new
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end
opts.on_tail("--version", "Show......version") do
puts OptionParser::Version.join('.')
exit
end
//}
@see OptionParser#on, OptionParser#on_head... -
OptionParser
:: Arguable # getopts(short _ opt , *long _ opt) -> Hash (11112.0) -
指定された short_opt や long_opt に応じて自身をパースし、結果を Hash として返します。
...指定された short_opt や long_opt に応じて自身をパースし、結果を Hash として返します。
コマンドラインに - もしくは -- を指定した場合、それ以降の解析を行ないません。
@param short_opt ショートネームのオプション(-f や -fx)......オプションが引数をとる場合は直後に ":" を付けます。
@param long_opt ロングネームのオプション(--version や --bufsize=512)を文字列で指定をします。
オプションが引数をとる場合は後ろに ":" を付けます。......す。
@raise OptionParser::ParseError 自身のパースに失敗した場合、発生します。
実際は OptionParser::ParseError のサブク
ラスの例外になります。
//emlist[t.rb][ruby]{
require 'optparse'
params = AR... -
NEWS for Ruby 2
. 7 . 0 (138.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...は ChangeLog ファイルか bugs.ruby-lang.org の issue を参照してください。
== 2.6.0 以降の変更
=== 言語仕様の変更
==== パターンマッチ
* パターンマッチが実験的機能として導入されました。 14912
//emlist[][ruby]{
case [0, [1, 2, 3]]
in [a,......ject without a block (ArgumentError)
//}
==== その他の変更
* 始端なしRangeが実験的に導入されました。
caseやComparable#clampや定数やDSLなどで便利かもしれません。
14799
//emlist[][ruby]{
ary[..3] # identical to ary[0..3]
case RUBY_VERSION
when ........*" のデフォルトの charset が ISO-8859-1 から UTF-8 に
なりました。 15933
* OptionParser
* 不明なオプションに対して "Did you mean?" が表示されるようになりました。 16256
//emlist[test.rb][ruby]{
require "optparse"
OptionParser.new do |opts|
o... -
NEWS for Ruby 3
. 0 . 0 (90.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...positional arguments.
Code that resulted in deprecation warnings in Ruby 2.7 will now
result in ArgumentError or different behavior. 14183
* Procs accepting a single rest argument and keywords are no longer
subject to autosplatting. This now matches the behavior of Procs
accepting......One-line pattern matching is redesigned. [EXPERIMENTAL]
* `=>` is added. It can be used like a rightward assignment.
17260
* `in` is changed to return `true` or `false`. 17371
//emlist{
0 => a
p a #=> 0
{b: 0, c: 1} => {b:}
p b #=> 0
//}
//emlist{
# version 3.0
0 in 1 #=......y issues
* Default gems
* The following libraries are promoted to default gems from stdlib.
* English
* abbrev
* base64
* drb
* debug
* erb
* find
* net-ftp
* net-http
* net-imap
* net-protocol
* open-uri
* optparse...