Class: Neptuno::CLI::Base

Inherits:
Dry::CLI::Command
  • Object
show all
Includes:
TTY::Command, TTY::Config, TTY::File, TTY::Prompt
Defined in:
lib/neptuno/cli/base.rb

Overview

Base cli class for Neptuno

Constant Summary collapse

ABORT_MESSAGE =
"fatal: not a Neptuno repository (or any of the parent directories)"

Constants included from TTY::Command

TTY::Command::TTY, TTY::Command::TTYP

Constants included from TTY::Config

TTY::Config::TTY

Constants included from TTY::File

TTY::File::TTY

Constants included from TTY::Prompt

TTY::Prompt::TTY

Instance Method Summary collapse

Methods included from TTY::Command

#command, #command_p, #neptuno_command

Methods included from TTY::Config

#auto_restart_procs, #config, #configured_services, #docker_compose_hash, #docker_compose_services, #get_dependants, #healthy_services, #json_services_status, #running_services, #services, #services_with_procs, #starting_services

Methods included from TTY::File

#file, #in_service?, #make_service_files, #neptuno_path, #project, #service

Methods included from TTY::Prompt

#prompt

Constructor Details

#initializeBase

Returns a new instance of Base.



14
15
16
17
18
# File 'lib/neptuno/cli/base.rb', line 14

def initialize
  abort ABORT_MESSAGE if neptuno_path == ""
  config.append_path(neptuno_path)
  config.read
end

Instance Method Details

#command_service_to(request, service_as_args: "") {|chosen_service, project| ... } ⇒ Object

Yields:



20
21
22
23
24
25
# File 'lib/neptuno/cli/base.rb', line 20

def command_service_to(request, service_as_args: "")
  chosen_service ||= service_as_args.to_a.empty? ? nil : service_as_args
  chosen_service ||= service if in_service?
  chosen_service ||= prompt.select("Command service to #{request}:", services)
  yield chosen_service, project
end

#command_services_to(request, all: nil, services_as_args: []) {|chosen_services, project| ... } ⇒ Object

Yields:



27
28
29
30
31
32
33
34
# File 'lib/neptuno/cli/base.rb', line 27

def command_services_to(request, all: nil, services_as_args: [])
  chosen_services = services if all
  chosen_services ||= services_as_args.to_a.empty? ? nil : services_as_args
  chosen_services ||= [service] if in_service?
  chosen_services ||= configured_services.to_a.empty? ? nil : configured_services
  chosen_services ||= prompt.multi_select("Command services to #{request}:", services)
  yield chosen_services, project
end