Passing parameters to Capistrano

前端 未结 5 773
感情败类
感情败类 2021-01-31 16:44

I\'m looking into the possibility of using Capistrano as a generic deploy solution. By \"generic\", I mean not-rails. I\'m not happy with the quality of the documentation I\'m f

5条回答
  •  耶瑟儿~
    2021-01-31 17:18

    As Jamie already showed, you can pass parameters to tasks with the -s flag. I want to show you how you additionally can use a default value.

    If you want to work with default values, you have to use fetch instead of ||= or checking for nil:

    namespace :logs do
      task :tail do
        file = fetch(:file, 'production') # sets 'production' as default value
        puts "I would use #{file}.log now"
      end
    end
    

    You can either run this task by (uses the default value production for file)

    $ cap logs:tail
    

    or (uses the value cron for file

    $ cap logs:tail -s file=cron
    

提交回复
热议问题