class Pry::Command::ChangePrompt

Public Instance Methods

options(opt) click to toggle source
# File lib/pry/commands/change_prompt.rb, line 16
def options(opt)
  opt.on(:l, :list, 'List the available prompts')
end
process(prompt) click to toggle source
# File lib/pry/commands/change_prompt.rb, line 20
def process(prompt)
  if opts.present?(:l)
    list_prompts
  else
    change_prompt(prompt)
  end
end

Private Instance Methods

change_prompt(prompt) click to toggle source
# File lib/pry/commands/change_prompt.rb, line 38
def change_prompt(prompt)
  if Pry::Prompt[prompt]
    pry_instance.prompt = Pry::Prompt[prompt]
  else
    raise Pry::CommandError,
          "'#{prompt}' isn't a known prompt. Run `change-prompt --list` " \
          "to see the list of known prompts."
  end
end
list_prompts() click to toggle source
# File lib/pry/commands/change_prompt.rb, line 30
def list_prompts
  prompts = Pry::Prompt.all.map do |name, prompt|
    "#{bold(name)}#{red(' (selected)') if pry_instance.prompt == prompt}\n" +
      prompt.description
  end
  output.puts(prompts.join("\n" * 2))
end