Skip to content

Instantly share code, notes, and snippets.

@unfunco
Created September 6, 2017 09:38
Show Gist options
  • Save unfunco/5f350ae54df7362511c6621023f946aa to your computer and use it in GitHub Desktop.
Save unfunco/5f350ae54df7362511c6621023f946aa to your computer and use it in GitHub Desktop.
Rake tasks for Symfony console commands
require 'json'
# Retrieves all the available Symfony console commands and creates a Rake task
# for each. In it's current generic state, this proxies the Rake task to the
# Symfony console, but this can be changed easily to execute the command within
# a containerised or virtualised environment.
SF_CONSOLE_COMMANDS = JSON.parse(`bin/console list --format=json`)['commands']
SF_CONSOLE_COMMANDS.each do |command, _|
task_name, task_description = command.values_at('name', 'description')
desc task_description
task task_name do
`bin/console #{task_name}`
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment