我已经查看了所有内容(谷歌搜索),我无法为我的生活弄清楚如何做到这一点。是否可以获得当前类中定义的雷神任务列表?我正在尝试编写一个方法来确定传递给 thor 的参数是否有效,为此,我需要一个所有已定义任务的列表。我可以在某个常量中创建一个列表,但如果可能的话,我宁愿使用内置工具。
前任:
#!/usr/bin/env ruby
require 'thor'
class Foo < Thor
desc 'task_1', 'The first task'
def task_1
puts 1
end #task_1
desc 'task_2', 'The second task'
def task_2
puts 2
end #task_2
desc 'check_args', 'Checks that the arguments are valid.', :hide => true
# get a list of the tasks defined in this class and check against ARGV
if !valid
invoke :help
exit
end #if
end #check_args
end #Foo
如果我的问题不够清楚,或者我只是在处理这一切都错了,请告诉我:)
谢谢