Module: CommandCenter
- Extended by:
- BuiltinCommands
- Defined in:
- lib/rust/helpers/rush_control.rb,
lib/rust/helpers/command_center.rb
Overview
Created by me on 2011-12-17.
Copyright (c) 2011. All pwnage reserved.
Class Method Summary
collapse
builtins, cd, commands, exit, help, ls, parser, pwd, read, register, register_builtin, rm, test, type
Class Method Details
.add_to_buffer(text) ⇒ Object
30
31
32
33
34
|
# File 'lib/rust/helpers/rush_control.rb', line 30
def add_to_buffer(text)
Rust.io.line += text
Rust.io.backspace_limit += text.length
print text
end
|
.capture(keystroke, &b) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/rust/helpers/rush_control.rb', line 22
def capture(keystroke, &b)
$keys ||= {}
if keystroke =~ /C-(\w)/
key_trap = $1
end
$keys[key_trap.unpack('c')[0] - 96] = b
end
|
.keys ⇒ Object
18
19
20
|
# File 'lib/rust/helpers/rush_control.rb', line 18
def keys
$keys
end
|
.run_as_builtin(args) ⇒ Object
46
47
48
49
50
51
52
53
54
|
# File 'lib/rust/helpers/command_center.rb', line 46
def run_as_builtin(args)
arr = args.split(' ')
cmd = arr.shift
if builtin_commands.include? cmd.to_sym
eval(cmd + ' ' + (arr.size > 0 ? arr.string.join(', ') : ''))
else
false
end
end
|
.run_as_command(*args) ⇒ Object
71
72
73
74
|
# File 'lib/rust/helpers/command_center.rb', line 71
def run_as_command(*args)
cmd = args.shift
exec(::Paths.find_path(cmd), args.join(' '))
end
|
.run_as_internal(args) ⇒ Object
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/rust/helpers/command_center.rb', line 56
def run_as_internal(args)
arr = args.split(' ')
cmd = arr.shift
if builtins.include? cmd.to_sym
eval(cmd + (arr.size > 0 ? ' ' + arr.string.join(', ') : '()'))
else
false
end
end
|
.run_as_ruby(line) ⇒ Object
67
68
69
|
# File 'lib/rust/helpers/command_center.rb', line 67
def run_as_ruby(line)
eval(line)
end
|
.run_standard(args_as_string) ⇒ Object
is the default command runner
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/rust/helpers/command_center.rb', line 31
def run_standard args_as_string
args = Shellwords.shellwords(args_as_string) cmd = args.shift
if builtin_commands.include? cmd.to_sym eval(cmd + (args.size > 0 ? args.string.join(', ') : ''))
else exec(cmd, args.join(' ')) end
rescue => e
raise e
end
|