class Inventarium::CLI::Init

Constants

CLASSIFICATION_VALUES
STATUS_VALUES

Public Instance Methods

call(args: [], **) click to toggle source
# File lib/inventarium/cli/init.rb, line 17
def call(args: [], **)
  dir = args.first || './service.yaml'
  result = base_service_information

  pastel = Pastel.new
  printf "Generating a new service.yaml\t\t"

  TemplateGenerator.new.call(dir: dir, payload: result)

  puts "[#{pastel.green('DONE')}]"
end

Private Instance Methods

base_service_information() click to toggle source
# File lib/inventarium/cli/init.rb, line 31
def base_service_information
  prompt = TTY::Prompt.new
  name = prompt.ask('A name of the service:', required: true)

  key = prompt.ask("A uniq key for service (you can use only chars, integers, '_' and '-'):", required: true) do |q|
    q.validate(/\A[a-zA-Z0-9_-]+\Z/, "Invalid key value, please use only chars, integers and '-'")
  end

  classification = prompt.select("Choose service classification", CLASSIFICATION_VALUES, symbols: {marker: '>'})
  status = prompt.select("Choose service status", STATUS_VALUES, symbols: {marker: '>'})

  { name: name, key: key, classification: classification, status: status }
end