官术网_书友最值得收藏!

The command-line arguments

The most commonly used rake command-line argument is -T. It shows us a list of available rake tasks that you have already defined.

We have defined the default rake task, and if we try to show the list of all rake tasks, it should be there. However, take a look at what happens in real life using the following command:

$ rake -T

The list is empty. Why? The answer lies within Rake. Run the rake command with the -h option to get the whole list of arguments. Pay attention to the description of the -T option, as shown in the following command-line output:

-T, --tasks [PATTERN] Display the tasks (matching optional PATTERN) with descriptions, then exit.

Note

You can get more information on Rake in the repository at the following GitHub link at https://github.com/jimweirich/rake.

The word description is the cornerstone here. It's a new term that we should know. Additionally, there is also an optional description to name a rake task. However, it's recommended that you define it because you won't see the list of all the defined rake tasks that we've already seen. It will be inconvenient for you to read your Rakefile every time you try to run some rake task. Just accept it as a rule: always leave a description for the defined rake tasks.

Now, add a description to your rake tasks with the desc method call, as shown in the following lines of code:

desc "Says 'Hello, Rake'"
task :default do
  puts 'Hello, Rake.'
end

As you see, it's rather easy. Run the rake -T command again and you will see an output as shown:

$ rake -T
rake default # Says 'Hello, Rake'

Tip

If you want to list all the tasks even if they don't have descriptions, you can pass an -A option with the -T option to the rake command. The resulting command will look like this: rake -T -A.

主站蜘蛛池模板: 晋中市| 克山县| 河津市| 海淀区| 贺兰县| 那坡县| 铜梁县| 永州市| 和林格尔县| 大理市| 钟山县| 建平县| 读书| 柞水县| 凤冈县| 德州市| 陆川县| 嘉义市| 深水埗区| 连平县| 和龙市| 丹棱县| 东丰县| 台北县| 兴山县| 布拖县| 阿巴嘎旗| 根河市| 潜江市| 洮南市| 长丰县| 黄石市| 荆州市| 双江| 金乡县| 金寨县| 柳林县| 辉县市| 天祝| 鄂托克旗| 浏阳市|