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 commands are invoked:

thor my_scripts -h

Finally, if you change your namespace to default:

namespace :default

Your commands can be invoked with a shortcut. Instead of:

thor :my_command


566
567
568
569
570
571
572
# File 'lib/thor/base.rb', line 566

def namespace(name = nil)
  if name
    @namespace = name.to_s
  else
    @namespace ||= Thor::Util.namespace_from_thor_class(self)
  end
end