I have several Thor tasks depending on each other. I'd like to have access to the name of the one currently running so that I can use it in the logger messages.
I can use the self
object to find the task name but that's a Thor::Sandbox::MyClass
object and that piece of information is deeply positioned. Does anybody know a getter? Something like:
class MyCLI < Thor
def hello
puts "hello, I am the task #{self.taskname}"
end
end
May be this would work:
def fun
puts __method__
end
fun
#=> :fun
Also look in the caller
method. It returns the current execution stack as a string.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.