Class: Zae::Commands

Inherits:
Object
  • Object
show all
Defined in:
lib/zae/commands.rb

Overview

All Commands available

Constant Summary collapse

ACTIONS =
%i[clean build depends download info install installed remove search update upgrade].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommands

Returns a new instance of Commands.



19
20
21
# File 'lib/zae/commands.rb', line 19

def initialize
  Commands.create_commands
end

Class Method Details

.create_commandsObject

generate dynamically methods of every command



26
27
28
29
30
31
32
# File 'lib/zae/commands.rb', line 26

def self.create_commands
  ACTIONS.each do |name|
    define_method name do |arguments = []|
      Commands.exec name, arguments
    end
  end
end

.execObject



34
35
36
37
38
39
40
41
# File 'lib/zae/commands.rb', line 34

def self.exec(...)
  Translate.new(...)
           .to_s
           .then(&lambda { |command|
             puts "❯: #{command}"
             system command
           })
end