Sha256: 58d4fee888b1b88095c6abb551fce6f40a0978511378943923dedad0008a2b93

Contents?: true

Size: 981 Bytes

Versions: 1

Compression:

Stored size: 981 Bytes

Contents

module Enginery
  class CLI
    include Enginery::Helpers
    
    %w[controller route helper view spec model admin].each do |unit|
      define_method 'new_' + unit do |*args|
        run '"%s" g:%s %s' % [executable, unit, args.flatten*' ']
      end
    end

    def new_migration *args
      run '"%s" m %s' % [executable, args.flatten*' ']
    end

    def run_migration vector, force_run, file, setups
      run '"%s" m:%s:%s f:%s %s' % [executable, vector, force_run, file, setups]
    end

    def bundle task
      run 'bundle %s' % task, output_cmd: true
    end

    def executable
      $0
    end

    def run cmd, opts = {}
      opts[:output_cmd] && (o; o(cmd))
      PTY.spawn cmd do |r, w, pid|
        begin
          r.sync
          r.each_line do |line|
            o line.rstrip!
          end
        rescue Errno::EIO # simply ignoring this
        ensure
          ::Process.wait pid
        end
      end
      $? && $?.exitstatus == 0
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
my_enginery-0.2.8 lib/enginery/cli.rb