Class: Chagall::Compose

Inherits:
Base
  • Object
show all
Defined in:
lib/chagall/compose.rb

Overview

Build and execute command usign docker compose on server

Constant Summary

Constants inherited from Base

Base::LOG_LEVELS

Instance Attribute Summary collapse

Attributes inherited from Base

#logger, #ssh

Instance Method Summary collapse

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



6
7
8
# File 'lib/chagall/compose.rb', line 6

def arguments
  @arguments
end

#commandObject (readonly)

Returns the value of attribute command.



6
7
8
# File 'lib/chagall/compose.rb', line 6

def command
  @command
end

Instance Method Details

#executeObject



26
27
28
29
30
31
# File 'lib/chagall/compose.rb', line 26

def execute
  cmd = "cd #{Settings.instance.project_folder_path} && #{build_docker_compose_command} #{@command}"
  cmd << " #{@raw_args.join(" ")}" unless @raw_args.empty?

  ssh.execute(cmd, tty: true)
end

#parse(arguments) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/chagall/compose.rb', line 8

def parse(arguments)
  if arguments.empty?
    puts "ERROR: Missing required arguments"
    puts "Usage: chagall compose COMMAND [OPTIONS]"
    exit(1)
  end

  @command = arguments.shift

  @raw_args = arguments

  if @command.nil? || @command.empty?
    puts "ERROR: Command is required"
    puts "Usage: chagall compose COMMAND [OPTIONS]"
    exit(1)
  end
end