Sha256: 31be18a003c2806ea78a01ace1c99d6fd78df68c1dbaad8281d5bca50269b031
Contents?: true
Size: 736 Bytes
Versions: 18
Compression:
Stored size: 736 Bytes
Contents
#!/usr/bin/env ruby # frozen_string_literal: true $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__)) require 'tty-reader' require 'paint' Class.new do attr_reader :reader def initialize @reader = TTY::Reader.new(interrupt: :exit) shell end def quit_cmd?(cmd) cmd =~ /quit|exit/ end def ignored_cmd?(cmd) cmd =~ /shell/ || cmd.strip == '' end def command reader.read_line(Paint['coltrane ', '#FF5A00']) end def shell command .tap { |cmd| exit if quit_cmd?(cmd) } .tap { |cmd| shell and return if ignored_cmd?(cmd) } .yield_self { |cmd| %x{coltrane #{cmd}} } .yield_self { |response| puts ["\n", response, "\n"].join } shell end end.new
Version data entries
18 entries across 18 versions & 1 rubygems