irb 1.5.1 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +51 -50
- data/lib/irb/cmd/backtrace.rb +1 -1
- data/lib/irb/cmd/break.rb +1 -1
- data/lib/irb/cmd/catch.rb +1 -1
- data/lib/irb/cmd/chws.rb +6 -0
- data/lib/irb/cmd/continue.rb +1 -1
- data/lib/irb/cmd/debug.rb +23 -0
- data/lib/irb/cmd/delete.rb +1 -1
- data/lib/irb/cmd/edit.rb +3 -7
- data/lib/irb/cmd/finish.rb +1 -1
- data/lib/irb/cmd/help.rb +14 -0
- data/lib/irb/cmd/info.rb +1 -1
- data/lib/irb/cmd/irb_info.rb +3 -0
- data/lib/irb/cmd/load.rb +24 -10
- data/lib/irb/cmd/ls.rb +4 -0
- data/lib/irb/cmd/measure.rb +3 -0
- data/lib/irb/cmd/next.rb +1 -1
- data/lib/irb/cmd/nop.rb +24 -0
- data/lib/irb/cmd/pushws.rb +9 -0
- data/lib/irb/cmd/show_cmds.rb +39 -0
- data/lib/irb/cmd/show_source.rb +3 -5
- data/lib/irb/cmd/step.rb +2 -3
- data/lib/irb/cmd/subirb.rb +32 -6
- data/lib/irb/cmd/whereami.rb +3 -0
- data/lib/irb/ext/save-history.rb +1 -1
- data/lib/irb/extend-command.rb +42 -8
- data/lib/irb/init.rb +1 -1
- data/lib/irb/version.rb +2 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a14d4867e5744e554edbcd7e87f397bd01305fd2e5dca129bfa4d0a49abdd12
|
4
|
+
data.tar.gz: b6ed771b62fc49d60ac292a87cd5bafb2ec79b5715ec73bc816923fcb68de2ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0acdbeae9c9aa9a83677a903ddf5006f82dc2dd4697d1e089ec360d0f77f049ebbaf3492b3ca5bda0a7c8814bac0e5ccde351e5a2d2c487170761d874204f02c
|
7
|
+
data.tar.gz: 4f92f7aadb2876a4d774ac52f27701cb8c723f400000a560f2452779b9562ad0d1a202b4534a52029662d0a2f910cdd816bdf43e275b800211c9ec062ae1241e
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -42,56 +42,57 @@ The Readline extension module can be used with irb. Use of Readline is default i
|
|
42
42
|
|
43
43
|
## Commands
|
44
44
|
|
45
|
-
The following commands are available on IRB.
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
45
|
+
The following commands are available on IRB. You can get the same output from the `show_cmds` command.
|
46
|
+
|
47
|
+
|
48
|
+
```
|
49
|
+
IRB
|
50
|
+
cwws Show the current workspace.
|
51
|
+
chws Change the current workspace to an object.
|
52
|
+
workspaces Show workspaces.
|
53
|
+
pushws Push an object to the workspace stack.
|
54
|
+
popws Pop a workspace from the workspace stack.
|
55
|
+
irb_load Load a Ruby file.
|
56
|
+
irb_require Require a Ruby file.
|
57
|
+
source Loads a given file in the current session.
|
58
|
+
irb Start a child IRB.
|
59
|
+
jobs List of current sessions.
|
60
|
+
fg Switches to the session of the given number.
|
61
|
+
kill Kills the session with the given number.
|
62
|
+
irb_info Show information about IRB.
|
63
|
+
show_cmds List all available commands and their description.
|
64
|
+
|
65
|
+
Debugging
|
66
|
+
debug Start the debugger of debug.gem.
|
67
|
+
break Start the debugger of debug.gem and run its `break` command.
|
68
|
+
catch Start the debugger of debug.gem and run its `catch` command.
|
69
|
+
next Start the debugger of debug.gem and run its `next` command.
|
70
|
+
delete Start the debugger of debug.gem and run its `delete` command.
|
71
|
+
step Start the debugger of debug.gem and run its `step` command.
|
72
|
+
continue Start the debugger of debug.gem and run its `continue` command.
|
73
|
+
finish Start the debugger of debug.gem and run its `finish` command.
|
74
|
+
backtrace Start the debugger of debug.gem and run its `backtrace` command.
|
75
|
+
info Start the debugger of debug.gem and run its `info` command.
|
76
|
+
|
77
|
+
Misc
|
78
|
+
edit Open a file with the editor command defined with `ENV["EDITOR"]`.
|
79
|
+
measure `measure` enables the mode to measure processing time. `measure :off` disables it.
|
80
|
+
|
81
|
+
Context
|
82
|
+
show_doc Enter the mode to look up RI documents.
|
83
|
+
ls Show methods, constants, and variables. `-g [query]` or `-G [query]` allows you to filter out the output.
|
84
|
+
show_source Show the source code of a given method or constant.
|
85
|
+
whereami Show the source code around binding.irb again.
|
86
|
+
```
|
87
|
+
|
88
|
+
## Configuration
|
89
|
+
|
90
|
+
### Environment Variables
|
91
|
+
|
92
|
+
- `NO_COLOR`: Assigning a value to it disables IRB's colorization.
|
93
|
+
- `IRB_USE_AUTOCOMPLETE`: Setting it to `false` disables IRB's autocompletion.
|
94
|
+
- `EDITOR`: Its value would be used to open files by the `edit` command.
|
95
|
+
- `IRBRC`: The file specified would be evaluated as IRB's rc-file.
|
95
96
|
|
96
97
|
## Documentation
|
97
98
|
|
data/lib/irb/cmd/backtrace.rb
CHANGED
data/lib/irb/cmd/break.rb
CHANGED
data/lib/irb/cmd/catch.rb
CHANGED
data/lib/irb/cmd/chws.rb
CHANGED
@@ -19,12 +19,18 @@ module IRB
|
|
19
19
|
module ExtendCommand
|
20
20
|
|
21
21
|
class CurrentWorkingWorkspace < Nop
|
22
|
+
category "IRB"
|
23
|
+
description "Show the current workspace."
|
24
|
+
|
22
25
|
def execute(*obj)
|
23
26
|
irb_context.main
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
27
30
|
class ChangeWorkspace < Nop
|
31
|
+
category "IRB"
|
32
|
+
description "Change the current workspace to an object."
|
33
|
+
|
28
34
|
def execute(*obj)
|
29
35
|
irb_context.change_workspace(*obj)
|
30
36
|
irb_context.main
|
data/lib/irb/cmd/continue.rb
CHANGED
data/lib/irb/cmd/debug.rb
CHANGED
@@ -5,6 +5,9 @@ module IRB
|
|
5
5
|
|
6
6
|
module ExtendCommand
|
7
7
|
class Debug < Nop
|
8
|
+
category "Debugging"
|
9
|
+
description "Start the debugger of debug.gem."
|
10
|
+
|
8
11
|
BINDING_IRB_FRAME_REGEXPS = [
|
9
12
|
'<internal:prelude>',
|
10
13
|
binding.method(:irb).source_location.first,
|
@@ -52,6 +55,13 @@ module IRB
|
|
52
55
|
end
|
53
56
|
end
|
54
57
|
|
58
|
+
module SkipPathHelperForIRB
|
59
|
+
def skip_internal_path?(path)
|
60
|
+
# The latter can be removed once https://github.com/ruby/debug/issues/866 is resolved
|
61
|
+
super || path.match?(IRB_DIR) || path.match?('<internal:prelude>')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
55
65
|
def setup_debugger
|
56
66
|
unless defined?(DEBUGGER__::SESSION)
|
57
67
|
begin
|
@@ -72,6 +82,8 @@ module IRB
|
|
72
82
|
end
|
73
83
|
frames
|
74
84
|
end
|
85
|
+
|
86
|
+
DEBUGGER__::ThreadClient.prepend(SkipPathHelperForIRB)
|
75
87
|
end
|
76
88
|
|
77
89
|
true
|
@@ -108,5 +120,16 @@ module IRB
|
|
108
120
|
end
|
109
121
|
end
|
110
122
|
end
|
123
|
+
|
124
|
+
class DebugCommand < Debug
|
125
|
+
def self.category
|
126
|
+
"Debugging"
|
127
|
+
end
|
128
|
+
|
129
|
+
def self.description
|
130
|
+
command_name = self.name.split("::").last.downcase
|
131
|
+
"Start the debugger of debug.gem and run its `#{command_name}` command."
|
132
|
+
end
|
133
|
+
end
|
111
134
|
end
|
112
135
|
end
|
data/lib/irb/cmd/delete.rb
CHANGED
data/lib/irb/cmd/edit.rb
CHANGED
@@ -6,6 +6,9 @@ module IRB
|
|
6
6
|
|
7
7
|
module ExtendCommand
|
8
8
|
class Edit < Nop
|
9
|
+
category "Misc"
|
10
|
+
description 'Open a file with the editor command defined with `ENV["EDITOR"]`.'
|
11
|
+
|
9
12
|
class << self
|
10
13
|
def transform_args(args)
|
11
14
|
# Return a string literal as is for backward compatibility
|
@@ -15,13 +18,6 @@ module IRB
|
|
15
18
|
args.strip.dump
|
16
19
|
end
|
17
20
|
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def string_literal?(args)
|
22
|
-
sexp = Ripper.sexp(args)
|
23
|
-
sexp && sexp.size == 2 && sexp.last&.first&.first == :string_literal
|
24
|
-
end
|
25
21
|
end
|
26
22
|
|
27
23
|
def execute(*args)
|
data/lib/irb/cmd/finish.rb
CHANGED
data/lib/irb/cmd/help.rb
CHANGED
@@ -16,6 +16,20 @@ module IRB
|
|
16
16
|
|
17
17
|
module ExtendCommand
|
18
18
|
class Help < Nop
|
19
|
+
class << self
|
20
|
+
def transform_args(args)
|
21
|
+
# Return a string literal as is for backward compatibility
|
22
|
+
if args.empty? || string_literal?(args)
|
23
|
+
args
|
24
|
+
else # Otherwise, consider the input as a String for convenience
|
25
|
+
args.strip.dump
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
category "Context"
|
31
|
+
description "Enter the mode to look up RI documents."
|
32
|
+
|
19
33
|
def execute(*names)
|
20
34
|
require 'rdoc/ri/driver'
|
21
35
|
opts = RDoc::RI::Driver.process_args([])
|
data/lib/irb/cmd/info.rb
CHANGED
data/lib/irb/cmd/irb_info.rb
CHANGED
data/lib/irb/cmd/load.rb
CHANGED
@@ -17,18 +17,29 @@ module IRB
|
|
17
17
|
# :stopdoc:
|
18
18
|
|
19
19
|
module ExtendCommand
|
20
|
-
class
|
20
|
+
class LoaderCommand < Nop
|
21
21
|
include IrbLoader
|
22
22
|
|
23
|
-
def
|
24
|
-
|
23
|
+
def raise_cmd_argument_error
|
24
|
+
raise CommandArgumentError.new("Please specify the file name.")
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
class
|
29
|
-
|
28
|
+
class Load < LoaderCommand
|
29
|
+
category "IRB"
|
30
|
+
description "Load a Ruby file."
|
31
|
+
|
32
|
+
def execute(file_name = nil, priv = nil)
|
33
|
+
raise_cmd_argument_error unless file_name
|
34
|
+
irb_load(file_name, priv)
|
35
|
+
end
|
36
|
+
end
|
30
37
|
|
31
|
-
|
38
|
+
class Require < LoaderCommand
|
39
|
+
category "IRB"
|
40
|
+
description "Require a Ruby file."
|
41
|
+
def execute(file_name = nil)
|
42
|
+
raise_cmd_argument_error unless file_name
|
32
43
|
|
33
44
|
rex = Regexp.new("#{Regexp.quote(file_name)}(\.o|\.rb)?")
|
34
45
|
return false if $".find{|f| f =~ rex}
|
@@ -56,13 +67,16 @@ module IRB
|
|
56
67
|
end
|
57
68
|
end
|
58
69
|
|
59
|
-
class Source <
|
60
|
-
|
61
|
-
|
70
|
+
class Source < LoaderCommand
|
71
|
+
category "IRB"
|
72
|
+
description "Loads a given file in the current session."
|
73
|
+
|
74
|
+
def execute(file_name = nil)
|
75
|
+
raise_cmd_argument_error unless file_name
|
76
|
+
|
62
77
|
source_file(file_name)
|
63
78
|
end
|
64
79
|
end
|
65
80
|
end
|
66
|
-
|
67
81
|
# :startdoc:
|
68
82
|
end
|
data/lib/irb/cmd/ls.rb
CHANGED
@@ -9,6 +9,9 @@ module IRB
|
|
9
9
|
|
10
10
|
module ExtendCommand
|
11
11
|
class Ls < Nop
|
12
|
+
category "Context"
|
13
|
+
description "Show methods, constants, and variables. `-g [query]` or `-G [query]` allows you to filter out the output."
|
14
|
+
|
12
15
|
def self.transform_args(args)
|
13
16
|
if match = args&.match(/\A(?<args>.+\s|)(-g|-G)\s+(?<grep>[^\s]+)\s*\n\z/)
|
14
17
|
args = match[:args]
|
@@ -30,6 +33,7 @@ module IRB
|
|
30
33
|
o.dump("instance variables", obj.instance_variables)
|
31
34
|
o.dump("class variables", klass.class_variables)
|
32
35
|
o.dump("locals", locals)
|
36
|
+
nil
|
33
37
|
end
|
34
38
|
|
35
39
|
def dump_methods(o, klass, obj)
|
data/lib/irb/cmd/measure.rb
CHANGED
data/lib/irb/cmd/next.rb
CHANGED
data/lib/irb/cmd/nop.rb
CHANGED
@@ -13,17 +13,41 @@ module IRB
|
|
13
13
|
# :stopdoc:
|
14
14
|
|
15
15
|
module ExtendCommand
|
16
|
+
class CommandArgumentError < StandardError; end
|
17
|
+
|
16
18
|
class Nop
|
19
|
+
class << self
|
20
|
+
def category(category = nil)
|
21
|
+
@category = category if category
|
22
|
+
@category
|
23
|
+
end
|
24
|
+
|
25
|
+
def description(description = nil)
|
26
|
+
@description = description if description
|
27
|
+
@description
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def string_literal?(args)
|
33
|
+
sexp = Ripper.sexp(args)
|
34
|
+
sexp && sexp.size == 2 && sexp.last&.first&.first == :string_literal
|
35
|
+
end
|
36
|
+
end
|
17
37
|
|
18
38
|
if RUBY_ENGINE == "ruby" && RUBY_VERSION >= "2.7.0"
|
19
39
|
def self.execute(conf, *opts, **kwargs, &block)
|
20
40
|
command = new(conf)
|
21
41
|
command.execute(*opts, **kwargs, &block)
|
42
|
+
rescue CommandArgumentError => e
|
43
|
+
puts e.message
|
22
44
|
end
|
23
45
|
else
|
24
46
|
def self.execute(conf, *opts, &block)
|
25
47
|
command = new(conf)
|
26
48
|
command.execute(*opts, &block)
|
49
|
+
rescue CommandArgumentError => e
|
50
|
+
puts e.message
|
27
51
|
end
|
28
52
|
end
|
29
53
|
|
data/lib/irb/cmd/pushws.rb
CHANGED
@@ -18,12 +18,18 @@ module IRB
|
|
18
18
|
|
19
19
|
module ExtendCommand
|
20
20
|
class Workspaces < Nop
|
21
|
+
category "IRB"
|
22
|
+
description "Show workspaces."
|
23
|
+
|
21
24
|
def execute(*obj)
|
22
25
|
irb_context.workspaces.collect{|ws| ws.main}
|
23
26
|
end
|
24
27
|
end
|
25
28
|
|
26
29
|
class PushWorkspace < Workspaces
|
30
|
+
category "IRB"
|
31
|
+
description "Push an object to the workspace stack."
|
32
|
+
|
27
33
|
def execute(*obj)
|
28
34
|
irb_context.push_workspace(*obj)
|
29
35
|
super
|
@@ -31,6 +37,9 @@ module IRB
|
|
31
37
|
end
|
32
38
|
|
33
39
|
class PopWorkspace < Workspaces
|
40
|
+
category "IRB"
|
41
|
+
description "Pop a workspace from the workspace stack."
|
42
|
+
|
34
43
|
def execute(*obj)
|
35
44
|
irb_context.pop_workspace(*obj)
|
36
45
|
super
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "stringio"
|
4
|
+
require_relative "nop"
|
5
|
+
|
6
|
+
module IRB
|
7
|
+
# :stopdoc:
|
8
|
+
|
9
|
+
module ExtendCommand
|
10
|
+
class ShowCmds < Nop
|
11
|
+
category "IRB"
|
12
|
+
description "List all available commands and their description."
|
13
|
+
|
14
|
+
def execute(*args)
|
15
|
+
commands_info = IRB::ExtendCommandBundle.all_commands_info
|
16
|
+
commands_grouped_by_categories = commands_info.group_by { |cmd| cmd[:category] }
|
17
|
+
longest_cmd_name_length = commands_info.map { |c| c[:display_name] }.max { |a, b| a.length <=> b.length }.length
|
18
|
+
|
19
|
+
output = StringIO.new
|
20
|
+
|
21
|
+
commands_grouped_by_categories.each do |category, cmds|
|
22
|
+
output.puts Color.colorize(category, [:BOLD])
|
23
|
+
|
24
|
+
cmds.each do |cmd|
|
25
|
+
output.puts " #{cmd[:display_name].to_s.ljust(longest_cmd_name_length)} #{cmd[:description]}"
|
26
|
+
end
|
27
|
+
|
28
|
+
output.puts
|
29
|
+
end
|
30
|
+
|
31
|
+
puts output.string
|
32
|
+
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# :startdoc:
|
39
|
+
end
|
data/lib/irb/cmd/show_source.rb
CHANGED
@@ -9,6 +9,9 @@ module IRB
|
|
9
9
|
|
10
10
|
module ExtendCommand
|
11
11
|
class ShowSource < Nop
|
12
|
+
category "Context"
|
13
|
+
description "Show the source code of a given method or constant."
|
14
|
+
|
12
15
|
class << self
|
13
16
|
def transform_args(args)
|
14
17
|
# Return a string literal as is for backward compatibility
|
@@ -62,11 +65,6 @@ module IRB
|
|
62
65
|
end
|
63
66
|
first_line
|
64
67
|
end
|
65
|
-
|
66
|
-
def string_literal?(args)
|
67
|
-
sexp = Ripper.sexp(args)
|
68
|
-
sexp && sexp.size == 2 && sexp.last&.first&.first == :string_literal
|
69
|
-
end
|
70
68
|
end
|
71
69
|
|
72
70
|
def execute(str = nil)
|
data/lib/irb/cmd/step.rb
CHANGED
@@ -6,10 +6,9 @@ module IRB
|
|
6
6
|
# :stopdoc:
|
7
7
|
|
8
8
|
module ExtendCommand
|
9
|
-
class Step <
|
9
|
+
class Step < DebugCommand
|
10
10
|
def execute(*args)
|
11
|
-
|
12
|
-
super(pre_cmds: "next", do_cmds: ["step", *args].join(" "))
|
11
|
+
super(do_cmds: ["step", *args].join(" "))
|
13
12
|
end
|
14
13
|
end
|
15
14
|
end
|
data/lib/irb/cmd/subirb.rb
CHANGED
@@ -10,31 +10,57 @@
|
|
10
10
|
#
|
11
11
|
|
12
12
|
require_relative "nop"
|
13
|
-
require_relative "../ext/multi-irb"
|
14
13
|
|
15
14
|
module IRB
|
16
15
|
# :stopdoc:
|
17
16
|
|
18
17
|
module ExtendCommand
|
19
|
-
class
|
18
|
+
class MultiIRBCommand < Nop
|
19
|
+
def initialize(conf)
|
20
|
+
super
|
21
|
+
extend_irb_context
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def extend_irb_context
|
27
|
+
# this extension patches IRB context like IRB.CurrentContext
|
28
|
+
require_relative "../ext/multi-irb"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class IrbCommand < MultiIRBCommand
|
33
|
+
category "IRB"
|
34
|
+
description "Start a child IRB."
|
35
|
+
|
20
36
|
def execute(*obj)
|
21
37
|
IRB.irb(nil, *obj)
|
22
38
|
end
|
23
39
|
end
|
24
40
|
|
25
|
-
class Jobs <
|
41
|
+
class Jobs < MultiIRBCommand
|
42
|
+
category "IRB"
|
43
|
+
description "List of current sessions."
|
44
|
+
|
26
45
|
def execute
|
27
46
|
IRB.JobManager
|
28
47
|
end
|
29
48
|
end
|
30
49
|
|
31
|
-
class Foreground <
|
32
|
-
|
50
|
+
class Foreground < MultiIRBCommand
|
51
|
+
category "IRB"
|
52
|
+
description "Switches to the session of the given number."
|
53
|
+
|
54
|
+
def execute(key = nil)
|
55
|
+
raise CommandArgumentError.new("Please specify the id of target IRB job (listed in the `jobs` command).") unless key
|
33
56
|
IRB.JobManager.switch(key)
|
34
57
|
end
|
35
58
|
end
|
36
59
|
|
37
|
-
class Kill <
|
60
|
+
class Kill < MultiIRBCommand
|
61
|
+
category "IRB"
|
62
|
+
description "Kills the session with the given number."
|
63
|
+
|
38
64
|
def execute(*keys)
|
39
65
|
IRB.JobManager.kill(*keys)
|
40
66
|
end
|
data/lib/irb/cmd/whereami.rb
CHANGED
data/lib/irb/ext/save-history.rb
CHANGED
@@ -70,7 +70,7 @@ module IRB
|
|
70
70
|
end
|
71
71
|
history_file = IRB.rc_file("_history") unless history_file
|
72
72
|
if File.exist?(history_file)
|
73
|
-
open(history_file, "r:#{IRB.conf[:LC_MESSAGES].encoding}") do |f|
|
73
|
+
File.open(history_file, "r:#{IRB.conf[:LC_MESSAGES].encoding}") do |f|
|
74
74
|
f.each { |l|
|
75
75
|
l = l.chomp
|
76
76
|
if self.class == RelineInputMethod and history.last&.end_with?("\\")
|
data/lib/irb/extend-command.rb
CHANGED
@@ -45,14 +45,15 @@ module IRB # :nodoc:
|
|
45
45
|
[:quit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
|
46
46
|
]
|
47
47
|
|
48
|
+
|
48
49
|
@EXTEND_COMMANDS = [
|
49
50
|
[
|
50
51
|
:irb_current_working_workspace, :CurrentWorkingWorkspace, "cmd/chws",
|
52
|
+
[:cwws, NO_OVERRIDE],
|
53
|
+
[:pwws, NO_OVERRIDE],
|
51
54
|
[:irb_print_working_workspace, OVERRIDE_ALL],
|
52
55
|
[:irb_cwws, OVERRIDE_ALL],
|
53
56
|
[:irb_pwws, OVERRIDE_ALL],
|
54
|
-
[:cwws, NO_OVERRIDE],
|
55
|
-
[:pwws, NO_OVERRIDE],
|
56
57
|
[:irb_current_working_binding, OVERRIDE_ALL],
|
57
58
|
[:irb_print_working_binding, OVERRIDE_ALL],
|
58
59
|
[:irb_cwb, OVERRIDE_ALL],
|
@@ -60,10 +61,10 @@ module IRB # :nodoc:
|
|
60
61
|
],
|
61
62
|
[
|
62
63
|
:irb_change_workspace, :ChangeWorkspace, "cmd/chws",
|
63
|
-
[:irb_chws, OVERRIDE_ALL],
|
64
|
-
[:irb_cws, OVERRIDE_ALL],
|
65
64
|
[:chws, NO_OVERRIDE],
|
66
65
|
[:cws, NO_OVERRIDE],
|
66
|
+
[:irb_chws, OVERRIDE_ALL],
|
67
|
+
[:irb_cws, OVERRIDE_ALL],
|
67
68
|
[:irb_change_binding, OVERRIDE_ALL],
|
68
69
|
[:irb_cb, OVERRIDE_ALL],
|
69
70
|
[:cb, NO_OVERRIDE],
|
@@ -77,16 +78,16 @@ module IRB # :nodoc:
|
|
77
78
|
],
|
78
79
|
[
|
79
80
|
:irb_push_workspace, :PushWorkspace, "cmd/pushws",
|
80
|
-
[:irb_pushws, OVERRIDE_ALL],
|
81
81
|
[:pushws, NO_OVERRIDE],
|
82
|
+
[:irb_pushws, OVERRIDE_ALL],
|
82
83
|
[:irb_push_binding, OVERRIDE_ALL],
|
83
84
|
[:irb_pushb, OVERRIDE_ALL],
|
84
85
|
[:pushb, NO_OVERRIDE],
|
85
86
|
],
|
86
87
|
[
|
87
88
|
:irb_pop_workspace, :PopWorkspace, "cmd/pushws",
|
88
|
-
[:irb_popws, OVERRIDE_ALL],
|
89
89
|
[:popws, NO_OVERRIDE],
|
90
|
+
[:irb_popws, OVERRIDE_ALL],
|
90
91
|
[:irb_pop_binding, OVERRIDE_ALL],
|
91
92
|
[:irb_popb, OVERRIDE_ALL],
|
92
93
|
[:popb, NO_OVERRIDE],
|
@@ -131,7 +132,7 @@ module IRB # :nodoc:
|
|
131
132
|
:irb_catch, :Catch, "cmd/catch",
|
132
133
|
],
|
133
134
|
[
|
134
|
-
:irb_next, :Next, "cmd/next"
|
135
|
+
:irb_next, :Next, "cmd/next"
|
135
136
|
],
|
136
137
|
[
|
137
138
|
:irb_delete, :Delete, "cmd/delete",
|
@@ -161,6 +162,7 @@ module IRB # :nodoc:
|
|
161
162
|
|
162
163
|
[
|
163
164
|
:irb_help, :Help, "cmd/help",
|
165
|
+
[:show_doc, NO_OVERRIDE],
|
164
166
|
[:help, NO_OVERRIDE],
|
165
167
|
],
|
166
168
|
|
@@ -187,9 +189,41 @@ module IRB # :nodoc:
|
|
187
189
|
:irb_whereami, :Whereami, "cmd/whereami",
|
188
190
|
[:whereami, NO_OVERRIDE],
|
189
191
|
],
|
190
|
-
|
192
|
+
[
|
193
|
+
:irb_show_cmds, :ShowCmds, "cmd/show_cmds",
|
194
|
+
[:show_cmds, NO_OVERRIDE],
|
195
|
+
]
|
191
196
|
]
|
192
197
|
|
198
|
+
|
199
|
+
@@commands = []
|
200
|
+
|
201
|
+
def self.all_commands_info
|
202
|
+
return @@commands unless @@commands.empty?
|
203
|
+
user_aliases = IRB.CurrentContext.command_aliases.each_with_object({}) do |(alias_name, target), result|
|
204
|
+
result[target] ||= []
|
205
|
+
result[target] << alias_name
|
206
|
+
end
|
207
|
+
|
208
|
+
@EXTEND_COMMANDS.each do |cmd_name, cmd_class, load_file, *aliases|
|
209
|
+
if !defined?(ExtendCommand) || !ExtendCommand.const_defined?(cmd_class, false)
|
210
|
+
require_relative load_file
|
211
|
+
end
|
212
|
+
|
213
|
+
klass = ExtendCommand.const_get(cmd_class, false)
|
214
|
+
aliases = aliases.map { |a| a.first }
|
215
|
+
|
216
|
+
if additional_aliases = user_aliases[cmd_name]
|
217
|
+
aliases += additional_aliases
|
218
|
+
end
|
219
|
+
|
220
|
+
display_name = aliases.shift || cmd_name
|
221
|
+
@@commands << { display_name: display_name, description: klass.description, category: klass.category }
|
222
|
+
end
|
223
|
+
|
224
|
+
@@commands
|
225
|
+
end
|
226
|
+
|
193
227
|
# Convert a command name to its implementation class if such command exists
|
194
228
|
def self.load_command(command)
|
195
229
|
command = command.to_sym
|
data/lib/irb/init.rb
CHANGED
@@ -45,7 +45,7 @@ module IRB # :nodoc:
|
|
45
45
|
|
46
46
|
@CONF[:USE_SINGLELINE] = false unless defined?(ReadlineInputMethod)
|
47
47
|
@CONF[:USE_COLORIZE] = (nc = ENV['NO_COLOR']).nil? || nc.empty?
|
48
|
-
@CONF[:USE_AUTOCOMPLETE] = true
|
48
|
+
@CONF[:USE_AUTOCOMPLETE] = ENV.fetch("IRB_USE_AUTOCOMPLETE", "true") != "false"
|
49
49
|
@CONF[:INSPECT_MODE] = true
|
50
50
|
@CONF[:USE_TRACER] = false
|
51
51
|
@CONF[:USE_LOADER] = false
|
data/lib/irb/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: irb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aycabta
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-12-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: reline
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- lib/irb/cmd/next.rb
|
66
66
|
- lib/irb/cmd/nop.rb
|
67
67
|
- lib/irb/cmd/pushws.rb
|
68
|
+
- lib/irb/cmd/show_cmds.rb
|
68
69
|
- lib/irb/cmd/show_source.rb
|
69
70
|
- lib/irb/cmd/step.rb
|
70
71
|
- lib/irb/cmd/subirb.rb
|
@@ -125,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
126
|
- !ruby/object:Gem::Version
|
126
127
|
version: '0'
|
127
128
|
requirements: []
|
128
|
-
rubygems_version: 3.3.
|
129
|
+
rubygems_version: 3.3.7
|
129
130
|
signing_key:
|
130
131
|
specification_version: 4
|
131
132
|
summary: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
|