Module: CommandKit::CommandName

Extended by:
ModuleMethods
Included in:
Commands, Examples, Help::Man, Usage, XDG
Defined in:
lib/command_kit/command_name.rb

Overview

Defines or derives a command class'es command-name.

Examples

Implicit

class MyCmd

  include CommandKit::CommandName

end

MyCmd.command_name
# => "my_cmd"

Explicit

class MyCmd

  include CommandKit::CommandName

  commnad_name 'foo-cmd'

end

MyCmd.command_name
# => "foo-cmd"

Defined Under Namespace

Modules: ClassMethods, ModuleMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ModuleMethods

included

Instance Attribute Details

#command_nameString (readonly)

The commands name.

Returns:

  • (String)


89
90
91
# File 'lib/command_kit/command_name.rb', line 89

def command_name
  @command_name
end

Instance Method Details

#initialize(command_name: self.class.command_name, **kwargs) ⇒ Object

Initializes command_name.

Parameters:

  • command_name (String) (defaults to: self.class.command_name)

    Overrides the command name. Defaults to self.class.command_name.



100
101
102
103
104
# File 'lib/command_kit/command_name.rb', line 100

def initialize(command_name: self.class.command_name, **kwargs)
  @command_name = command_name

  super(**kwargs)
end