Class: RubyCode::Views::BashApproval

Inherits:
Object
  • Object
show all
Defined in:
lib/rubycode/views/bash_approval.rb

Overview

Builds bash command approval prompt display

Class Method Summary collapse

Class Method Details

.build(command:, base_command:, safe_commands:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rubycode/views/bash_approval.rb', line 9

def self.build(command:, base_command:, safe_commands:)
  pastel = Pastel.new

  [
    "",
    pastel.red("━" * 80),
    pastel.bold.red("⚠ WARNING: Non-Whitelisted Command"),
    "#{pastel.cyan("Command:")} #{command}",
    "#{pastel.cyan("Base command:")} #{base_command}",
    pastel.red("─" * 80),
    pastel.yellow("This command is not in the safe whitelist:"),
    pastel.dim("Safe commands: #{safe_commands.join(", ")}"),
    "",
    pastel.yellow("⚠ Only approve if you trust this command will not cause harm"),
    pastel.red("━" * 80)
  ].join("\n")
end