Module: Brute::Prompts::Environment

Defined in:
lib/brute/prompts/environment.rb

Class Method Summary collapse

Class Method Details

.call(ctx) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/brute/prompts/environment.rb', line 6

def self.call(ctx)
  cwd = ctx[:cwd] || Dir.pwd
  model = ctx[:model_name].to_s
  git = File.exist?(File.join(cwd, ".git"))

  parts = []
  parts << "You are powered by the model named #{model}." unless model.empty?
  parts << ""
  parts << "Here is some useful information about the environment you are running in:"
  parts << "<env>"
  parts << "  Working directory: #{cwd}"
  parts << "  Is directory a git repo: #{git ? "yes" : "no"}"
  parts << "  Platform: #{RUBY_PLATFORM}"
  parts << "  Today's date: #{Time.now.strftime("%a %b %d %Y")}"
  parts << "</env>"
  parts.join("\n")
end