Sha256: 42b161cc33e9c9d87525fb6caa54b4133e79b9fef5843fb3f1d5112eae42baa5

Contents?: true

Size: 888 Bytes

Versions: 1

Compression:

Stored size: 888 Bytes

Contents

require 'space/logger'
require 'readline'
require 'thread'

module Space
  class App
    attr_reader :name, :project, :screen

    def initialize(name)
      @name    = name
      @project = Model::Project.new(name)
      @screen  = Screen.new(project)
    end

    def run
      screen.display
      project.refresh
      cli_loop
      # Thread.new(&method(:cli_loop))
      # sleep
      puts
    end

    private

      def cli_loop
        loop do
          print "\e[3;0H"
          line = Readline.readline(prompt, true) || break
          handle(line)
        end
      rescue Exception => e
        log e.message, e.backtrace
      end

      def handle(line)
        Action::Handler.new(project).run(line) unless line.empty?
      end

      def prompt
        "#{project.repos.scoped? ? project.repos.scope.map { |r| r.name }.join(', ') : project.name} > "
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
space-0.0.6 lib/space/app.rb