Class: RubynCode::CLI::Commands::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyn_code/cli/commands/base.rb

Overview

Abstract base class for all slash commands.

Subclasses must implement:

- self.command_name  

Optionally override:

- self.aliases 

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.aliases ⇒ Object



26
27
28
# File 'lib/rubyn_code/cli/commands/base.rb', line 26

def aliases
  [].freeze
end

.all_names ⇒ Array<String>

All names this command responds to (primary + aliases).

Returns:

  • (Array<String>)


37
38
39
# File 'lib/rubyn_code/cli/commands/base.rb', line 37

def all_names
  [command_name, *aliases].freeze
end

.command_name ⇒ Object

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/rubyn_code/cli/commands/base.rb', line 18

def command_name
  raise NotImplementedError, "#{name} must define self.command_name"
end

.description ⇒ Object

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/rubyn_code/cli/commands/base.rb', line 22

def description
  raise NotImplementedError, "#{name} must define self.description"
end

.hidden? ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/rubyn_code/cli/commands/base.rb', line 30

def hidden?
  false
end

Instance Method Details

#execute(args, ctx) ⇒ void

This method returns an undefined value.

Execute the command.

Parameters:

  • args (Array<String>) —

    arguments passed after the command name

  • ctx (Commands::Context) —

    shared context with REPL dependencies

Raises:

  • (NotImplementedError)


47
48
49
# File 'lib/rubyn_code/cli/commands/base.rb', line 47

def execute(args, ctx)
  raise NotImplementedError, "#{self.class.name}#execute must be implemented"
end