Class: Dri::Commands::Profile
- Inherits:
-
Dri::Command
- Object
- Dri::Command
- Dri::Commands::Profile
- Defined in:
- lib/dri/commands/profile.rb
Instance Method Summary collapse
- #execute(_input: $stdin, output: $stdout) ⇒ Object
-
#initialize(options) ⇒ Profile
constructor
A new instance of Profile.
- #pretty_print_profile ⇒ Object
Methods inherited from Dri::Command
#add_color, #api_client, #bold, #command, #config, #cursor, #editor, #emoji, #handover_report_path, #logger, #ops_token, #pastel, #profile, #prompt, #spinner, #timezone, #token, #username, #verify_config_exists
Constructor Details
#initialize(options) ⇒ Profile
Returns a new instance of Profile.
10 11 12 |
# File 'lib/dri/commands/profile.rb', line 10 def initialize() @options = end |
Instance Method Details
#execute(_input: $stdin, output: $stdout) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dri/commands/profile.rb', line 14 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? width = handover_report_path.nil? ? 30 : 75 frame_args = { width: width, height: 10, align: :left, 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 |
#pretty_print_profile ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/dri/commands/profile.rb', line 40 def pretty_print_profile <<~PROFILE #{add_color('User:', :bright_cyan)} #{username}#{' '} #{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} #{add_color('Report Path:', :bright_cyan)} #{handover_report_path} PROFILE end |