部署rake任务,就像它是一个公共脚本一样。

时间:2021-03-27 00:28:16

I like the rake task structure and rake utilities.. I want to create a script that can do many things, and rake seems the logical choice.
I want to know how can I make it look like a regular script:

我喜欢rake任务结构和rake实用工具。我想创建一个可以做很多事情的脚本,rake似乎是合乎逻辑的选择。我想知道如何使它看起来像一个普通的脚本:

./myscript.rb cake:bake

as opposed to

而不是

rake -f myscript.rb cake:bake

any idea? Of course, rake must still be installed etc.. simply to make it easier to use...

任何想法?当然,rake仍然必须安装等。只是为了更容易使用……

2 个解决方案

#1


6  

myscript.rb:

myscript.rb:

#!/usr/bin/ruby

require 'rubygems'
require 'rake'

namespace :cake do
  task :bake do
    puts "Baking cake..."
  end
end

Rake::Task[ARGV.first].execute

Then on the command line:

然后在命令行上:

chmod +x myscript.rb
./myscript.rb cake:bake

#2


0  

I found this for cygwin / windows

这是我为cygwin / windows找到的

http://errtheblog.com/posts/60-sake-bomb

http://errtheblog.com/posts/60-sake-bomb

removes the dependency on rails and let's you have rake tasks installed and available globally

删除对rails的依赖,让我们安装rake任务并在全局范围内可用

#1


6  

myscript.rb:

myscript.rb:

#!/usr/bin/ruby

require 'rubygems'
require 'rake'

namespace :cake do
  task :bake do
    puts "Baking cake..."
  end
end

Rake::Task[ARGV.first].execute

Then on the command line:

然后在命令行上:

chmod +x myscript.rb
./myscript.rb cake:bake

#2


0  

I found this for cygwin / windows

这是我为cygwin / windows找到的

http://errtheblog.com/posts/60-sake-bomb

http://errtheblog.com/posts/60-sake-bomb

removes the dependency on rails and let's you have rake tasks installed and available globally

删除对rails的依赖,让我们安装rake任务并在全局范围内可用