[英]How can I retrieve the current command name in a Thor method?
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. 我可以使用
self
对象找到任务名称,但这是一个Thor::Sandbox::MyClass
对象,并且该信息的位置很深。 Does anybody know a getter? 有人知道吸气剂吗? Something like:
就像是:
class MyCLI < Thor
def hello
puts "hello, I am the task #{self.taskname}"
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.