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
107
108
109
110
111
|
# File 'lib/reditor/command.rb', line 107
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.
9
10
11
|
# File 'lib/reditor/command.rb', line 9
def restarted
@restarted
end
|
Class Method Details
.restart(args) ⇒ Object
11
12
13
14
15
|
# File 'lib/reditor/command.rb', line 11
def restart(args)
self.restarted = true
start args
end
|
Instance Method Details
#open(name = nil) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/reditor/command.rb', line 27
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
42
43
44
45
46
47
48
49
|
# File 'lib/reditor/command.rb', line 42
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
52
53
54
|
# File 'lib/reditor/command.rb', line 52
def version
say "Reditor version #{VERSION}"
end
|