Sha256: d7a40a3cca4a16d69d510a2041fdb9794f9d22846daa46e748e3393b218f348b

Contents?: true

Size: 1.38 KB

Versions: 5

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

require_relative '../command'

require 'tty-box'

module Dri
  module Commands
    class Profile < Dri::Command
      def initialize(options)
        @options = options
      end

      def execute(input: $stdin, output: $stdout)
        if config.exist? && @options["edit"]
          editor.open(config.source_file)
          return
        end

        logger.info "🔎 Looking for profiles...\n"

        if config.exist?
          frame_args = {
            width: 30,
            height: 10,
            align: :center,
            padding: 1,
            border: :thick,
            title: { top_left: add_color('PROFILE:', :bright_cyan) }
          }
          output.print TTY::Box.frame(**frame_args) { pretty_print_profile.strip }
          output.puts "☝️ To modify this profile try passing #{add_color('dri profile --edit', :yellow)}.\n"
        else
          logger.error "Oops.. Profile not found. Try creating one using #{add_color('dri init', :yellow)}."
        end
      end

      def pretty_print_profile
        <<~PROFILE
          #{add_color('User:', :bright_cyan)} #{username}\n #{add_color('Token:', :bright_cyan)} #{token}
          #{add_color('OpsToken:', :bright_cyan)} #{ops_token}
          #{add_color('Timezone:', :bright_cyan)} #{timezone}
          #{add_color('Emoji:', :bright_cyan)} #{emoji}
        PROFILE
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dri-0.9.0 lib/dri/commands/profile.rb
dri-0.8.0 lib/dri/commands/profile.rb
dri-0.7.0 lib/dri/commands/profile.rb
dri-0.6.1 lib/dri/commands/profile.rb
dri-0.6.0 lib/dri/commands/profile.rb