6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/cksh_commander/runner.rb', line 6
def self.run(command, params)
require_constants!
data = CKSHCommander::Data.new(params)
begin
name = "#{command.capitalize}::Command"
cmd = Kernel.const_get(name).new(data)
response = cmd.authenticated? ? cmd.run : Response.new("Invalid token!")
rescue => e
text = if e.is_a?(UnauthorizedError)
"You are unauthorized to use this subcommand!"
else
cmd && cmd.debugging? ? e.message :
cmd ? cmd.error_message : "Command not found..."
end
response = Response.new(text)
end
response
end
|