Method: Thor::Base::ClassMethods#namespace
- Defined in:
- lib/thor/base.rb
#namespace(name = nil) ⇒ Object
Sets the namespace for the Thor or Thor::Group class. By default the namespace is retrieved from the class name. If your Thor class is named Scripts::MyScript, the help method, for example, will be called as:
thor scripts:my_script -h
If you change the namespace:
namespace :my_scripts
You change how your tasks are invoked:
thor my_scripts -h
Finally, if you change your namespace to default:
namespace :default
Your tasks can be invoked with a shortcut. Instead of:
thor :my_task
370 371 372 373 374 375 376 377 |
# File 'lib/thor/base.rb', line 370 def namespace(name=nil) case name when nil @namespace ||= Thor::Util.namespace_from_thor_class(self) else @namespace = name.to_s end end |