Class: Reditor::Command
- Inherits:
-
Thor
- Object
- Thor
- Reditor::Command
show all
- Defined in:
- lib/reditor/command.rb
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
112
113
114
115
116
|
# File 'lib/reditor/command.rb', line 112
def method_missing(name, *args, &block)
return super if Command.restarted
Command.restart ['open', name.to_s, *args]
end
|
Class Attribute Details
.restarted ⇒ Object
Returns the value of attribute restarted.
8
9
10
|
# File 'lib/reditor/command.rb', line 8
def restarted
@restarted
end
|
Class Method Details
.restart(args) ⇒ Object
10
11
12
13
14
|
# File 'lib/reditor/command.rb', line 10
def restart(args)
self.restarted = true
start args
end
|
Instance Method Details
#open(name = nil) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/reditor/command.rb', line 26
def open(name = nil)
return invoke :help unless name
detect_exec name, global: options[:global] do |dir, file|
say "Moving to #{dir}", :green
Dir.chdir dir do
say "Opening #{file}", :green
exec editor_command, file
end
end
end
|
#sh(name) ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'lib/reditor/command.rb', line 41
def sh(name)
detect_exec name, global: options[:global] do |dir, _|
say "Moving to #{dir}", :green
Dir.chdir dir do
exec shell_command
end
end
end
|
#version ⇒ Object
51
52
53
|
# File 'lib/reditor/command.rb', line 51
def version
say "Reditor version #{VERSION}"
end
|