Sha256: f11e2834c797eff6cc2c9dda6c732bce80b3d8a3d02b8de0f2849ec0b183464c

Contents?: true

Size: 759 Bytes

Versions: 7

Compression:

Stored size: 759 Bytes

Contents

module Cumuli
  class CLI
    def run
      spawn_app
    end

    def args
      @args ||= Args.new(ARGV.dup)
    end

    def spawn_app
      listen_for_signals

      Dir.chdir(args.dir) do
        command = Commander.new("foreman start #{args.foreman_options}").build
        puts "starting ... #{command}"
        spawn_terminal(command)
      end
    end

    def signals
      # these are the signals used by Foreman
      ['TERM', 'INT', 'HUP']
    end

    def listen_for_signals
      signals.each do |signal|
        Signal.trap(signal) do
          kill_process
        end
      end
    end

    def kill_process
      Process.kill('INT', Process.pid)
    end

    def spawn_terminal(command)
      Terminal.new(command).spawn
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cumuli-0.5.0 lib/cumuli/cli/cli.rb
cumuli-0.4.1 lib/cumuli/cli/cli.rb
cumuli-0.4.0 lib/cumuli/cli/cli.rb
cumuli-0.3.4 lib/cumuli/cli/cli.rb
cumuli-0.3.2 lib/cumuli/cli/cli.rb
cumuli-0.3.1 lib/cumuli/cli/cli.rb
cumuli-0.3.0 lib/cumuli/cli/cli.rb