Sha256: 2add86796a8b29252b8716db339ddd7dec75a9312348a98e7f88943696527b2f
Contents?: true
Size: 1.52 KB
Versions: 2
Compression:
Stored size: 1.52 KB
Contents
require "tty-prompt" module Inventarium module CLI class Init < Dry::CLI::Command desc "Create an empty service.yml file for the service" example [ " # Generate service.yml in root folder", "./.service_meta/ # Generate service.yml in '.service_meta' folder", "order_service.yaml # Generate order_service.yml in root folder" ] CLASSIFICATION_VALUES = %w[critical normal internal experiment] STATUS_VALUES = %w[adopt hold trial in_development] 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 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 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
inventarium-0.3.1 | lib/inventarium/cli/init.rb |
inventarium-0.3.0 | lib/inventarium/cli/init.rb |