./bin/lux in lux-fw-0.5.37 vs ./bin/lux in lux-fw-0.6.2

- old
+ new

@@ -1,32 +1,36 @@ #!/usr/bin/env ruby # -*- mode: ruby -*- -if File.exists?('lux-fw.gemspec') +ENV['THOR_SILENCE_DEPRECATION'] = 'true' + +if File.exist?('lux-fw.gemspec') puts 'Cant run in lux folder' exit end require 'thor' require 'colorize' require 'optparse' -require 'awesome_print' +require 'amazing_print' require 'dotenv' +require 'whirly' +require_relative '../lib/overload/thread_simple' Dotenv.load LUX_ROOT = File.expand_path '../..', __FILE__ -puts 'Lux (%s, v%s)' % [LUX_ROOT, File.read('%s/.version' % LUX_ROOT)] unless ARGV[0] +puts 'Lux v%s (%s)' % [File.read('%s/.version' % LUX_ROOT), LUX_ROOT] unless ARGV[0] ### module Cli extend self def run what - puts what.green + puts what.light_black system what end def die text puts text.red @@ -38,19 +42,78 @@ end end ### -trap("SIGINT") { Cli.die 'ctrl+c exit' } +require 'pry' +AmazingPrint.pry! +# nice object dump in console +Pry.config.print = Proc.new do |output, data| + puts data.class.to_s.gray + + out = + if data.is_a?(Hash) + JSON.pretty_generate(data).gsub(/"([\w\-]+)":/) { '"%s":' % $1.yellow } + elsif data.is_a?(String) + if data.downcase.starts_with?('select') + require 'niceql' + Niceql::Prettifier.prettify_sql data + # elsif data.is_a?(String) && data.include?('</body>') + # require 'nokogiri' + # Nokogiri::XML(data, &:noblanks) + else + data + end + else + data.ai + end + + output.puts out unless data.nil? +end + +### + LuxCli = Class.new Thor -Dir['%s/bin/cli/*.rb' % LUX_ROOT].each { |it| load it } +# remove new in app, or allow only new while not in app +files = Dir['%s/bin/cli/*.rb' % LUX_ROOT] +filter = File.exist?('./Gemfile') ? :reject : :select +files = files.send(filter) { |name| name.include?('/new.rb') } +files.each { |it| load it } LuxCli.start ARGV -rakes = Dir['./Rakefile*'] + Dir['./rakefile*'] +### -if !ARGV[0] && rakes[0] - puts 'Or use one of rake tasks' - puts ' ' + `rake -T`.gsub($/, "\n ") +if !ARGV[0] && (Dir['./Rakefile*'] + Dir['./rakefile*'])[0] + Whirly.start spinner: "dots" do + t = Thread::Simple.new + t.add(:rake) { `rake -T` } + + if File.exist?('./Capfile') && ENV['RACK_ENV'] == 'development' + t.add(:capistrano) { `bundle exec cap -T` } + end + + if File.exist?('./config/deploy.rb') && ENV['RACK_ENV'] == 'development' + t.add(:mina) { `bundle exec mina -T` } + end + + t.run + + if t[:rake] + puts 'Rake tasks:' + puts ' ' + t[:rake].gsub($/, "\n ") + end + + if t[:capistrano] + puts 'Capinstrano tasks:' + puts ' ' + t[:capistrano].gsub($/, "\n ") + end + + if t[:mina] + puts 'Mina tasks:' + puts ' ' + t[:mina].gsub($/, "\n ") + end + end end +