Class: Makit::Rake::ListCommand
- Inherits:
-
Clamp::Command
- Object
- Clamp::Command
- Makit::Rake::ListCommand
- Defined in:
- lib/makit/rake/cli.rb
Overview
Command to list available rake tasks
Instance Method Summary collapse
Instance Method Details
#execute ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/makit/rake/cli.rb', line 94 def execute target_path = resolve_target(target) signal_usage_error "Target directory does not exist: #{target_path}" unless Dir.exist?(target_path) Dir.chdir(target_path) do puts "Available rake tasks in #{target_path}:".colorize(:blue) # Build rake command to list tasks rake_cmd = "rake --tasks" rake_cmd += " --all" if all? # Execute and capture output output = `#{rake_cmd} 2>/dev/null` if output.empty? puts "No rake tasks found or Rakefile not present".colorize(:yellow) return end # Filter by pattern if specified output = output.lines.select { |line| line.include?(pattern) }.join if pattern puts output end end |