diff options
author | schneems <richard.schneeman@gmail.com> | 2013-11-11 17:35:04 -0500 |
---|---|---|
committer | schneems <richard.schneeman@gmail.com> | 2013-12-19 15:43:03 -0600 |
commit | 3fa4e1671fcf903069df88071c473f3a186ee896 (patch) | |
tree | cc4da1938026edf452270df56d0a00912b699f08 /railties | |
parent | 04ad814bb992e854927c1bec3422df882f017ab6 (diff) | |
download | rails-3fa4e1671fcf903069df88071c473f3a186ee896.tar.gz rails-3fa4e1671fcf903069df88071c473f3a186ee896.tar.bz2 rails-3fa4e1671fcf903069df88071c473f3a186ee896.zip |
Make `rails runner` command options more obvious
We're surrounding the options in angle brackets `<>` as is convention in `curl`:
```
$ curl --help
Usage: curl [options...] <url>
```
And then in square brackets `[]` with bars `|` as in `tar`:
```
$ tar --help
...
Create: tar -c [options] [<file> | <dir> | @<archive> | -C <dir> ]
```
To further clarify that the command can be used with both, we now show examples:
```
Examples:
rails runner 'puts Rails.env'
This runs the code `puts Rails.env` after loading the app
rails runner path/to/filename.rb
This runs the Ruby file located at `path/to/filename.rb` after loading the app
```
This format was taken from the `find` man pages:
```
EXAMPLES
The following examples are shown as given to the shell:
find / \! -name "*.c" -print
Print out a list of all the files whose names do not end in .c.
find / -newer ttt -user wnj -print
Print out a list of all the files owned by user ``wnj'' that are newer than the file ttt.
```
The the text at the bottom is also shifted to improve readability.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/commands/runner.rb | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/railties/lib/rails/commands/runner.rb b/railties/lib/rails/commands/runner.rb index dd2ee5639e..3a71f8d3f8 100644 --- a/railties/lib/rails/commands/runner.rb +++ b/railties/lib/rails/commands/runner.rb @@ -9,7 +9,7 @@ if ARGV.first.nil? end ARGV.clone.options do |opts| - opts.banner = "Usage: rails runner [options] ('Some.ruby(code)' or a filename)" + opts.banner = "Usage: rails runner [options] [<'Some.ruby(code)'> | <filename.rb>]" opts.separator "" @@ -22,14 +22,23 @@ ARGV.clone.options do |opts| opts.on("-h", "--help", "Show this help message.") { $stdout.puts opts; exit } + opts.separator "" + opts.separator "Examples: " + + opts.separator " rails runner 'puts Rails.env'" + opts.separator " This runs the code `puts Rails.env` after loading the app" + opts.separator "" + opts.separator " rails runner path/to/filename.rb" + opts.separator " This runs the Ruby file located at `path/to/filename.rb` after loading the app" + if RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ opts.separator "" opts.separator "You can also use runner as a shebang line for your executables:" - opts.separator "-------------------------------------------------------------" - opts.separator "#!/usr/bin/env #{File.expand_path($0)} runner" + opts.separator " -------------------------------------------------------------" + opts.separator " #!/usr/bin/env #{File.expand_path($0)} runner" opts.separator "" - opts.separator "Product.all.each { |p| p.price *= 2 ; p.save! }" - opts.separator "-------------------------------------------------------------" + opts.separator " Product.all.each { |p| p.price *= 2 ; p.save! }" + opts.separator " -------------------------------------------------------------" end opts.order! { |o| code_or_file ||= o } rescue retry |