Sha256: a45dbe88023f065ca5d040003dd2aeb3dccbcceadfdc87be6ccdc62a6a1a0b16

Contents?: true

Size: 1.23 KB

Versions: 6796

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

class Pry
  class Command
    class ChangePrompt < Pry::ClassCommand
      match 'change-prompt'
      group 'Input and Output'
      description 'Change the current prompt.'
      command_options argument_required: true
      banner <<-BANNER
        Usage: change-prompt [OPTIONS] [NAME]

        Change the current prompt.
      BANNER

      def options(opt)
        opt.on(:l, :list, 'List the available prompts')
      end

      def process(prompt)
        if opts.present?(:l)
          list_prompts
        else
          change_prompt(prompt)
        end
      end

      private

      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

      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

      Pry::Commands.add_command(self)
    end
  end
end

Version data entries

6,796 entries across 6,792 versions & 31 rubygems

Version Path
cybrid_api_organization_ruby-0.123.118 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
cybrid_api_bank_ruby-0.123.117 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
cybrid_api_id_ruby-0.123.117 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
cybrid_api_organization_ruby-0.123.117 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
cybrid_api_bank_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
cybrid_api_organization_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
cybrid_api_id_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
cybrid_api_bank_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
cybrid_api_id_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
cybrid_api_organization_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
ory-client-1.15.17 vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
cybrid_api_bank_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
cybrid_api_organization_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
cybrid_api_id_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
cybrid_api_organization_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
cybrid_api_bank_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
cybrid_api_id_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
cybrid_api_organization_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb
cybrid_api_bank_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/commands/change_prompt.rb