Module: Kiqr::Cli

Defined in:
lib/kiqr/cli.rb,
lib/kiqr/cli/extensions.rb,
lib/kiqr/cli/application.rb,
lib/kiqr/cli/generators/app/app_generator.rb,
lib/kiqr/cli/generators/dummy/dummy_generator.rb

Defined Under Namespace

Modules: Generators Classes: Application, Extensions

Class Method Summary collapse

Class Method Details

.exec_appObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/kiqr/cli.rb', line 20

def exec_app
  original_cwd = Dir.pwd
  ruby_exe = Gem.ruby

  loop do
    if exe = File.file?("bin/kiqr")
      exec ruby_exe, "bin/kiqr", *ARGV
      break # non reachable, hack to be able to stub exec in the test suite
    end

    # If we exhaust the search there is no executable, this could be a
    # call to generate a new application, so restore the original cwd.
    Dir.chdir(original_cwd) && return if Pathname.new(Dir.pwd).root?

    # Otherwise keep moving upwards in search of an executable.
    Dir.chdir("..")
  end
end

.runObject



16
17
18
# File 'lib/kiqr/cli.rb', line 16

def run
  exec_app || Kiqr::Cli::Application.start(ARGV)
end