Sha256: a182f9e7985e655dcd23ebf5a9e93dddd8cdb2f7f37547dde246cf9e9aee6ca5

Contents?: true

Size: 881 Bytes

Versions: 3

Compression:

Stored size: 881 Bytes

Contents

module SecretsCli
  class Init
    include SecretsCli::Helpers

    attr_reader :options

    def initialize(options)
      @options = options
    end

    def call
      SecretsCli::Configuration.write(config)
      prompt.ok "Written in #{SECRETS_CONFIG_FILE}:"
      prompt.ok File.read(SECRETS_CONFIG_FILE)
    end

    private

    def config
      {
        secrets_file: secrets_file,
        secrets_repo: secrets_repo,
        secrets_field: secrets_field
      }
    end

    def secrets_file
      @secrets_file ||= options.secrets_file || SecretsCli::Prompts::SecretsFile.new.call
    end

    def secrets_repo
      repo = options.secrets_repo || SecretsCli::Prompts::SecretsRepo.new.call
      repo << '/' unless repo.end_with?('/')
      repo
    end

    def secrets_field
      options.secrets_field || SecretsCli::Prompts::SecretsField.new.call
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
secrets_cli-0.2.0 lib/secrets_cli/init.rb
secrets_cli-0.1.1 lib/secrets_cli/init.rb
secrets_cli-0.1.0 lib/secrets_cli/init.rb