191件ヒット
[1-100件を表示]
(0.022秒)
別のキーワード
種類
- インスタンスメソッド (165)
- ライブラリ (11)
- クラス (11)
- 文書 (4)
ライブラリ
- optparse (176)
クラス
- OptionParser (165)
キーワード
-
NEWS for Ruby 3
. 0 . 0 (4) - OptionParser (11)
-
on
_ head (11) -
on
_ tail (11) - parse (22)
- parse! (11)
- separator (11)
- summarize (22)
-
summary
_ indent (11) -
summary
_ indent= (11) -
summary
_ width (11) -
summary
_ width= (11) -
to
_ a (11) -
to
_ s (11)
検索結果
先頭5件
-
optparse (38216.0)
-
コマンドラインのオプションを取り扱うためのライブラリです。
...コマンドラインのオプションを取り扱うためのライブラリです。
=== チュートリアル
optparse を使う場合、基本的には
(1) OptionParser オブジェクト opt を生成する。
(2) オプションを取り扱うブロックを opt に登録する。
(3) o......ptiondef
* optionarg
* longoption
* help
* subcmd
* argv
* hyphen_start_file
====[a:optiondef] オプションの定義
以下はオプション -a, -b を受け付けるコマンドを作成する例です。
//emlist[sample.rb][ruby]{
require 'optparse'
opt = OptionParser.new
opt.on('-a'......らオプションが取り除かれます。
これを避けるには OptionParser#parse を使います。
//emlist[sample.rb][ruby]{
require 'optparse'
opt = OptionParser.new
opt.on('-a') {|v| p v }
opt.on('-b') {|v| p v }
# parse() の場合、ARGVは変更されない。
# オプションを... -
OptionParser
# help -> String (26113.0) -
サマリの文字列を返します。
...ます。
//emlist[例][ruby]{
require "optparse"
options = {}
opts = OptionParser.new do |opts|
opts.banner = "Usage: example.rb [options]"
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
options[:verbose] = v
end
end
puts opts.help
# => Usage: example.rb [options]
# -v, -... -
OptionParser
# to _ s -> String (11013.0) -
サマリの文字列を返します。
...ます。
//emlist[例][ruby]{
require "optparse"
options = {}
opts = OptionParser.new do |opts|
opts.banner = "Usage: example.rb [options]"
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
options[:verbose] = v
end
end
puts opts.help
# => Usage: example.rb [options]
# -v, -... -
OptionParser
# on _ tail(*arg , &block) -> self (8042.0) -
オプションを取り扱うためのブロックを自身の持つリストの最後に登録します。
...最後に登録します。
--version や --help の説明をサマリの最後に表示したい時に便利です。
@param arg OptionParser#on と同様です。
@param block OptionParser#on と同様です。
//emlist[例][ruby]{
require "optparse"
opts = OptionParser.new do |opts|
opts.o......opts.on("-u", "--update")
opts.on_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... -
OptionParser
# on _ head(*arg , &block) -> self (8024.0) -
オプションを取り扱うためのブロックを自身の持つリストの最初に登録します。
...//emlist[例][ruby]{
require "optparse"
opts = OptionParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end
puts opts.help
# => Usage: test [options]
# -i, --init
# -u, --update
# -h, --help
//}
@see OptionParser#on, OptionPa... -
OptionParser
# summarize(to = [] , width = self . summary _ width , max = width - 1 , indent= self . summary _ indent) -> () (8024.0) -
サマリを指定された to へと加えていきます。
...ます。
//emlist[例][ruby]{
require "optparse"
opts = OptionParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end
opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
opts.summarize(["description\n"], 10......, 8, " ")
# => ["description\n", " -i\n", " --init\n", " -u\n", " --update\n", " -h\n", " --help\n"]
//}... -
OptionParser
# summarize(to = [] , width = self . summary _ width , max = width - 1 , indent= self . summary _ indent) {|line| . . . } -> () (8024.0) -
サマリを指定された to へと加えていきます。
...ます。
//emlist[例][ruby]{
require "optparse"
opts = OptionParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end
opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
opts.summarize(["description\n"], 10......, 8, " ")
# => ["description\n", " -i\n", " --init\n", " -u\n", " --update\n", " -h\n", " --help\n"]
//}... -
OptionParser
# summary _ indent -> String (8024.0) -
サマリを表示する時のインデントを文字列で返します。
...例][ruby]{
require "optparse"
opts = OptionParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end
opts.summary_indent # => " "
opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
opts.summary_ind......ent = " "
opts.summary_indent # => " "
opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
//}... -
OptionParser
# summary _ indent=(indent) (8024.0) -
サマリを表示する時のインデントを文字列で指定します。
...例][ruby]{
require "optparse"
opts = OptionParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end
opts.summary_indent # => " "
opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
opts.summary_ind......ent = " " # => " "
opts.summary_indent # => " "
opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
//}... -
OptionParser
# summary _ width -> Integer (8024.0) -
サマリを表示するときの幅を整数で返します。
...list[例][ruby]{
require "optparse"
opts = OptionParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end
opts.summary_width # => 32
opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
opts.summary_width =......8
opts.summary_width # =>8
opts.summarize
# => [" -i\n", " --init\n", " -u\n", " --update\n", " -h\n", " --help\n"]
//}...