зеркало из https://github.com/github/ruby.git
[ruby/irb] Add command line option to select which completor to use
(https://github.com/ruby/irb/pull/754) * Add command line option to select which completor to use * Add test for completor argv https://github.com/ruby/irb/commit/1dec2708c9
This commit is contained in:
Родитель
ae1fad4cd7
Коммит
c4efd17061
|
@ -330,6 +330,10 @@ module IRB # :nodoc:
|
|||
@CONF[:USE_AUTOCOMPLETE] = true
|
||||
when "--noautocomplete"
|
||||
@CONF[:USE_AUTOCOMPLETE] = false
|
||||
when "--regexp-completor"
|
||||
@CONF[:COMPLETOR] = :regexp
|
||||
when "--type-completor"
|
||||
@CONF[:COMPLETOR] = :type
|
||||
when /^--prompt-mode(?:=(.+))?/, /^--prompt(?:=(.+))?/
|
||||
opt = $1 || argv.shift
|
||||
prompt_mode = opt.upcase.tr("-", "_").intern
|
||||
|
|
|
@ -30,6 +30,9 @@ Usage: irb.rb [options] [programfile] [arguments]
|
|||
--nocolorize Don't use color-highlighting.
|
||||
--autocomplete Use auto-completion (default).
|
||||
--noautocomplete Don't use auto-completion.
|
||||
--regexp-completor
|
||||
Use regexp based completion (default).
|
||||
--type-completor Use type based completion.
|
||||
--prompt prompt-mode, --prompt-mode prompt-mode
|
||||
Set prompt mode. Pre-defined prompt modes are:
|
||||
'default', 'classic', 'simple', 'inf-ruby', 'xmp', 'null'.
|
||||
|
|
|
@ -21,6 +21,9 @@ Usage: irb.rb [options] [programfile] [arguments]
|
|||
--nocolorize 色付けを利用しない.
|
||||
--autocomplete オートコンプリートを利用する.
|
||||
--noautocomplete オートコンプリートを利用しない.
|
||||
--regexp-completor
|
||||
補完に正規表現を利用する.
|
||||
--type-completor 補完に型情報を利用する.
|
||||
--prompt prompt-mode/--prompt-mode prompt-mode
|
||||
プロンプトモードを切替えます. 現在定義されているプ
|
||||
ロンプトモードは, default, simple, xmp, inf-rubyが
|
||||
|
|
|
@ -140,6 +140,13 @@ Use autocompletion.
|
|||
Don't use autocompletion.
|
||||
.Pp
|
||||
.Pp
|
||||
.It Fl -regexp-completor
|
||||
Use regexp based completion.
|
||||
.Pp
|
||||
.It Fl -type-completor
|
||||
Use type based completion.
|
||||
.Pp
|
||||
.Pp
|
||||
.It Fl -verbose
|
||||
Show details.
|
||||
.Pp
|
||||
|
|
|
@ -120,6 +120,22 @@ module TestIRB
|
|||
IRB.conf[:USE_AUTOCOMPLETE] = orig_use_autocomplete_conf
|
||||
end
|
||||
|
||||
def test_completor_setup_with_argv
|
||||
orig_completor_conf = IRB.conf[:COMPLETOR]
|
||||
|
||||
# Default is :regexp
|
||||
IRB.setup(__FILE__, argv: [])
|
||||
assert_equal :regexp, IRB.conf[:COMPLETOR]
|
||||
|
||||
IRB.setup(__FILE__, argv: ['--type-completor'])
|
||||
assert_equal :type, IRB.conf[:COMPLETOR]
|
||||
|
||||
IRB.setup(__FILE__, argv: ['--regexp-completor'])
|
||||
assert_equal :regexp, IRB.conf[:COMPLETOR]
|
||||
ensure
|
||||
IRB.conf[:COMPLETOR] = orig_completor_conf
|
||||
end
|
||||
|
||||
def test_noscript
|
||||
argv = %w[--noscript -- -f]
|
||||
IRB.setup(eval("__FILE__"), argv: argv)
|
||||
|
|
Загрузка…
Ссылка в новой задаче