Skip to content

Commit 1d81200

Browse files
committed
Update README
1 parent c83f3d4 commit 1d81200

1 file changed

Lines changed: 19 additions & 20 deletions

File tree

README.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Rack::Console [![Build Status](https://travis-ci.org/davidcelis/rack-console.svg?branch=master)](https://travis-ci.org/davidcelis/rack-console)
1+
# Rack::Console
22

3-
Find yourself missing a `rails console` analogue in your other Ruby web applications? This lightweight gem provides a Rack::Console class that will load your Rack application's code and environment into an IRB or Pry session. Either use `Rack::Console.new.start` directly, or run the provided `rack-console` executable.
3+
Find yourself missing a `rails console` analogue in your other Ruby web applications? This lightweight gem provides a Rack::Console class that will load your Rack application's code and environment into an IRB or Pry session. Either use `Rack::Console.new(options).start` directly, or run the provided `rack-console` executable.
44

55
## Installation
66

77
Add this line to your application's Gemfile:
88

99
```ruby
10-
gem 'rack-console'
10+
gem "rack-console"
1111
```
1212

1313
And then execute:
@@ -25,47 +25,46 @@ $ gem install rack-console
2525
## Usage
2626

2727
Rack::Console ships with a `rack-console` executable that will load your application in an IRB shell (or
28-
[Pry](http://pryrepl.org) if that's included in your Gemfile). Assuming you have a `config.ru` file in the current directory, simply run:
28+
[Pry](http://pryrepl.org) if that's included in your Gemfile and you specify the `--pry` option). Assuming you have a `config.ru` file in the current directory, simply run:
2929

30-
```ruby
30+
```
3131
$ bundle exec rack-console
32-
pry(main)>
32+
Loading development environment (Rack::Console 2.0.0)
33+
irb(main):001>
3334
```
3435

35-
Rack::Console supports some of the same things that `rails console` provides, as well as arguments used in `rackup`:
36+
Rack::Console supports some of the same things that `rails console` provides, as well as some of the options used in `rackup`:
3637

3738
* An `app` method that will return your underlying Rack application with [rack-test](https://github.com/brynary/rack-test) methods mixed in. You can perform fake requests to your app (e.g. `response = app.get('/')`)
38-
* Supply the RACK_ENV as an argument (`bundle exec rack-console production`)
3939
* A `reload!` method to discard new code or defined variables/constants
4040
* The `-c` option (or `--config`) to specify a non-standard `config.ru` file
41+
* The `-e` option (or `--environment`) to specify the Rack environment to load
4142
* The `-r` option (or `--require`) to require a file/library before Rack::Console loads
4243
* The `-I` option (or `--include`) to specify paths (colon-separated) to add to `$LOAD_PATH` before Rack::Console loads
44+
* The `-P` option (or `--[no-]pry`) to specify whether to use Pry instead of IRB (Pry must be installed in your project)
4345

4446
## Framework CLI Example
4547

46-
Because Rack::Console is just a class, it's easy to provide a `console` subcommand to a CLI for your own Rack framework. For example, here's how you could hypothetically implement a `console` subcommand for a generic Rack CLI using [Thor](https://github.com/erikhuda/thor):
48+
Because Rack::Console is just a class, it's easy to provide a `console` subcommand to a CLI for your own Rack framework. For example, here's how you could hypothetically implement a `console` subcommand for a generic Rack CLI using [Thor](https://github.com/rails/thor):
4749

4850
```ruby
49-
require 'rack/console'
50-
require 'thor'
51+
require "rack/console"
52+
require "thor"
5153

5254
module Rack
5355
class CLI < Thor
54-
desc 'console [ENVIRONMENT]', 'Start a Rack console'
56+
desc "console [ENVIRONMENT]", "Start a Rack console"
5557

56-
method_option :config, aliases: '-c', type: 'string',
57-
desc: 'Specify a Rackup file (default: config.ru)'
58-
method_option :require, aliases: '-r', type: 'string',
59-
desc: 'Require a file/library before console boots'
60-
method_option :include, aliases: '-I', type: 'string',
61-
desc: 'Add colon-separated paths to $LOAD_PATH'
58+
method_option :config, aliases: "-c", type: "string", desc: "Specify a Rackup file (default: config.ru)"
59+
method_option :require, aliases: "-r", type: "string", desc: "Require a file/library before console boots"
60+
method_option :include, aliases: "-I", type: "string", desc: "Add colon-separated paths to $LOAD_PATH"
6261

6362
def console
6463
# Set a custom intro message:
65-
# ENV['RACK_CONSOLE_INTRO'] = 'Loading Rack::Console...'
64+
# ENV["RACK_CONSOLE_INTRO"] = "Loading Rack::Console..."
6665
#
6766
# Or, to prevent an intro message from being printed at all:
68-
# ENV['IGNORE_RACK_CONSOLE_INTRO'] = 'true'
67+
# ENV["IGNORE_RACK_CONSOLE_INTRO"] = "true"
6968
Rack::Console.new(options).start
7069
end
7170
end

0 commit comments

Comments
 (0)