Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set options per task #82

Open
mdesantis opened this issue May 26, 2016 · 1 comment
Open

Set options per task #82

mdesantis opened this issue May 26, 2016 · 1 comment
Labels

Comments

@mdesantis
Copy link

I have a Capistrano task for rails runner remote execution:

require 'shellwords'

namespace :invoke do

  desc "Execute rails runner on a remote server"
  task :runner do
    if ENV['COMMAND']
      on roles(:app) do
        within current_path do
          with rails_env: fetch(:rails_env) do
            execute :rails, :runner, ENV['COMMAND'].shellescape
          end
        end
      end

    else
      puts "\n\nFailed! You need to specify the 'COMMAND' parameter",
           "Usage: cap <stage> invoke:runner COMMAND=your-command"
    end
  end

end

In this task, but only in this one, I would like to disable truncation. Is it possible to access to Airbrussh formatter within the task in order to set truncation to false?

@mattbrictson
Copy link
Owner

Capistrano is not really designed to handle per-task logging options.

However, you could hack something together inside your task like this:

task :runner do
  original_truncate = Airbrussh.configuration.truncate
  Airbrussh.configuration.truncate = false
  begin
    # ...
  ensure
    Airbrussh.configuration.truncate = original_truncate
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants