Class: Bixby::App::Commands::Run

Inherits:
Bixby::App::Command show all
Defined in:
lib/bixby-client/app/commands/run.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Bixby::App::Command

command_name, desc, match

Class Method Details

.optionsObject



42
43
44
# File 'lib/bixby-client/app/commands/run.rb', line 42

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
# 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.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
  end

  setup_env()
  exec(scripts.shift, *argv)
end

#setup_envObject

Setup the ENV for exec



36
37
38
39
40
# File 'lib/bixby-client/app/commands/run.rb', line 36

def setup_env
  # stick ourselves in RUBYLIB to speedup exec time
  ENV["RUBYLIB"] = File.expand_path("../../../..", __FILE__)
  ENV["RUBYOPT"] = '-rbixby-client/script'
end