Class: Bixby::App::Commands::Run
Class Method Summary
collapse
Instance Method Summary
collapse
command_name, desc, match
Class Method Details
61
62
63
|
# File 'lib/bixby-client/app/commands/run.rb', line 61
def self.options
nil
end
|
Instance Method Details
#run(global_options, argv) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/bixby-client/app/commands/run.rb', line 13
def run(global_options, argv)
str = argv.shift
scripts = FileFinder.new(Bixby.repo).find_script(str)
if scripts.nil? then
$stderr.puts "Error: missing input"
$stderr.puts "usage: bixby run <script> [args ...]"
return exit 1
elsif scripts.kind_of?(Array)
if scripts.size > 1 then
$stderr.puts "Found #{scripts.size} scripts matching '#{str}'. Please be more explicit"
scripts.each do |s|
puts " * #{s}"
end
return 1
elsif scripts.empty? then
$stderr.puts "No scripts matched '#{str}'. Try again"
return 1
end
scripts = scripts.shift
end
setup_env()
exec(scripts, *argv)
end
|
#setup_env ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/bixby-client/app/commands/run.rb', line 46
def setup_env
path = ENV["PATH"].dup
ruby_dir = RbConfig::CONFIG['bindir']
if !path.include? ruby_dir then
ENV["PATH"] = "#{ruby_dir}:#{path}"
end
ENV["RUBYLIB"] = File.expand_path("../../../..", __FILE__)
ENV["RUBYOPT"] = '-rbixby-client/script'
end
|