Sha256: 00244bf435b1c517c5dc9ddac748ff1e90a0b083f52400c58de0be9016785c9b

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 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?
          box = TTY::Box.frame(width: 30, height: 10, align: :center, padding: 1, title: {top_left: add_color('PROFILE:', :bright_cyan)}, border: :thick) do
            pretty_print_profile
          end
          print box
          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
        "#{add_color('User:', :bright_cyan)} #{username}\n #{add_color('Token:', :bright_cyan)} #{token}\n #{add_color('Timezone:', :bright_cyan)} #{timezone}\n #{add_color('Emoji:', :bright_cyan)} #{emoji}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dri-0.1.3 lib/dri/commands/profile.rb
dri-0.1.2 lib/dri/commands/profile.rb
dri-0.1.1 lib/dri/commands/profile.rb
dri-0.1.0 lib/dri/commands/profile.rb