From 235d0e0806deecc15f59d2896a00be24762eea5f Mon Sep 17 00:00:00 2001 From: George Date: Tue, 23 Apr 2013 02:01:55 +0400 Subject: [PATCH 01/16] Clean Rakefile up --- Rakefile | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Rakefile b/Rakefile index 62b26d2..9091ebe 100644 --- a/Rakefile +++ b/Rakefile @@ -1,13 +1,8 @@ $LOAD_PATH.unshift 'lib' require "repl/version" -def version - Repl::VERSION -end - -def git(command) - system("git #{command}") -end +def version; Repl::VERSION end +def git(command); `git #{command}` end desc "Build manual" task :build_man do @@ -32,7 +27,7 @@ task :publish do end desc "Publish to GitHub Pages" -task :pages => [ :build_man ] do +task :pages => [:build_man] do cp "man/repl.1.html", "html" git "checkout gh-pages" mv "html", "index.html" From ea3bba11f4b269d0b75dee8857599bfb12bca58b Mon Sep 17 00:00:00 2001 From: George Date: Tue, 23 Apr 2013 13:27:46 +0400 Subject: [PATCH 02/16] Cleaning it up --- bin/repl | 120 ++++++++++---------------------------------- lib/repl/version.rb | 3 -- 2 files changed, 27 insertions(+), 96 deletions(-) delete mode 100644 lib/repl/version.rb diff --git a/bin/repl b/bin/repl index bd6a605..407d776 100644 --- a/bin/repl +++ b/bin/repl @@ -1,106 +1,40 @@ #!/usr/bin/env ruby +require 'optparse' +%w[INT TERM].each { |s| trap(s) { abort '' } } -# repl(1) -- sometimes you need a repl -# -# repl is an interactive program which tenderly wraps another, -# non-interactive program. -# -# For example: -# -# $ repl redis-cli -# >> set name chris -# OK -# >> get name -# chris -# -# If you have rlwrap(1) installed you'll get the full benefits of -# readline: history, reverse searches, etc. +options = {} +OptionParser.new do |o| + o.banner = 'Usage: repl [otions] command' + o.summary_width = 15 + o.version = '1.0.0' -def show_help - puts <<-help -Usage: repl [options] command ... + o.on('-d', '--debug', 'Display each command executed') { options[:debug] = true } + o.on('-s', '--stdin', "Pipe input to command's STDIN") { options[:stdin] = true } + o.on('-m', '--man', 'Display the man page') { exec "man #{File.dirname __FILE__}/../man/repl.1" } +end.parse! -Options: - --help Display this message - --stdin Pipe input to command's STDIN - --debug Display each command executed - --man Display the man page +program = ARGV.join ' ' +exec "#{$0} -h" if program.empty? -Bug reports, suggestions, updates: -http://http://github.com/defunkt/repl/issues -help - exit -end - -if ARGV.empty? || ARGV.any? { |arg| %w( -h --help -help help ).include?(arg) } - show_help -end - -if ARGV.include? '--man' - dir = File.dirname(__FILE__) - exec "man #{dir}/../man/repl.1" -end - -completion_dir = ENV['REPL_COMPLETION_DIR'] || "~/.repl" -if File.exists?(cdir = File.expand_path(completion_dir)) - script = ARGV.detect { |a| a !~ /^-/ } - if script - cfile = Dir[cdir + '/' + File.basename(script)].first - cfile = nil if cfile && !File.exists?(cfile) - end -end - -history_dir = ENV['REPL_HISTORY_DIR'] || "~/" -if File.exists?(hdir = File.expand_path(history_dir)) - if script = ARGV.detect { |a| a !~ /^-/ } - script = File.basename(script) - hfile = "#{hdir}/.#{script}_history" - end -end - -if !ENV['__REPL_WRAPPED'] && system("which rlwrap > /dev/null 2> /dev/null") - ENV['__REPL_WRAPPED'] = '0' +options[:completion] = Dir[completion_dir + '/' + File.basename(program)].first if + File.exists? completion_dir = File.expand_path(ENV['REPL_COMPLETION_DIR'] || '~/.repl') +options[:history] = "#{history_dir}/.#{File.basename program}_history" if + File.exists? history_dir = File.expand_path(ENV['REPL_HISTORY_DIR'] || '~/') - rlargs = "" - rlargs << " -f #{cfile}" if cfile - rlargs << " -H #{hfile}" if hfile - - exec "rlwrap #{rlargs} #$0 #{ARGV.join(' ')}" -end - -if ARGV[0] == '--debug' - debug = ARGV.delete('--debug') -end - -if ARGV.include? '--stdin' - from_stdin = ARGV.delete('--stdin') -end - -command = ARGV.join(' ') -show_help if command.empty? - -if debug +if options[:debug] print 'rlwrap ' if ENV['__REPL_WRAPPED'] - print "-f #{cfile} " if cfile - print "-H #{hfile} " if hfile - puts command.inspect + print "-f #{options[:completion]} " if options[:completion] + print "-H #{options[:history]} " if options[:history] + puts program.inspect end loop do print ENV['REPL_PROMPT'] || "#{ARGV[0]}>> " + line = STDIN.gets.chomp + + command = options[:stdin] ? "echo '%s' | #{program}" : "#{program} %s" + puts "$ #{command}" if options[:debug] - begin - line = $stdin.gets.chomp - rescue NoMethodError, Interrupt - exit - end - - if from_stdin - run = "echo \"%s\" | #{command}" % [ line, nil ] - else - run = "#{command} %s" % [ line, nil ] - end - puts "$ #{run}" if debug - system run - warn "Use Ctrl-D (i.e. EOF) to exit" if line =~ /^(exit|quit)$/ + system command % [line, nil] + warn 'Use Ctrl-D to exit' if line =~ /^(exit|quit)$/ end diff --git a/lib/repl/version.rb b/lib/repl/version.rb deleted file mode 100644 index 8e34404..0000000 --- a/lib/repl/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module Repl - VERSION = "1.0.0" -end From 2d04eb7119b570a14119dba31d50b241898b320c Mon Sep 17 00:00:00 2001 From: George Date: Tue, 23 Apr 2013 14:20:16 +0400 Subject: [PATCH 03/16] Now uses optparse std library --- LICENSE | 20 -------------------- "LICENS\320\225" | 22 ++++++++++++++++++++++ bin/repl | 34 +++++++++++++++++----------------- 3 files changed, 39 insertions(+), 37 deletions(-) delete mode 100644 LICENSE create mode 100644 "LICENS\320\225" mode change 100644 => 100755 bin/repl diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 2745bcc..0000000 --- a/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2009 Chris Wanstrath - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git "a/LICENS\320\225" "b/LICENS\320\225" new file mode 100644 index 0000000..da97908 --- /dev/null +++ "b/LICENS\320\225" @@ -0,0 +1,22 @@ +Copyright © 2009 Chris Wanstrath + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the “Software”), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +The software is provided “as is”, without warranty of any kind, +express or implied, including but not limited to the warranties +of merchantability, fitness for a particular purpose and +noninfrigement. In no event shall the authors or copyright +holders be liable for any claim, damages or other liability, +whether in an action of contract, tort or otherwise, arising +from, out of or in connection with the software or the use or +other dealings in the software. diff --git a/bin/repl b/bin/repl old mode 100644 new mode 100755 index 407d776..c53c93f --- a/bin/repl +++ b/bin/repl @@ -2,39 +2,39 @@ require 'optparse' %w[INT TERM].each { |s| trap(s) { abort '' } } -options = {} +arguments, options = ARGV.join(' '), {} OptionParser.new do |o| - o.banner = 'Usage: repl [otions] command' + o.banner = 'Usage: repl [options] command' o.summary_width = 15 o.version = '1.0.0' - o.on('-d', '--debug', 'Display each command executed') { options[:debug] = true } + o.on('-h', '--help', 'Display this message') { puts o; exit } o.on('-s', '--stdin', "Pipe input to command's STDIN") { options[:stdin] = true } + o.on('-d', '--debug', 'Display each command executed') { options[:debug] = true } o.on('-m', '--man', 'Display the man page') { exec "man #{File.dirname __FILE__}/../man/repl.1" } end.parse! program = ARGV.join ' ' exec "#{$0} -h" if program.empty? -options[:completion] = Dir[completion_dir + '/' + File.basename(program)].first if - File.exists? completion_dir = File.expand_path(ENV['REPL_COMPLETION_DIR'] || '~/.repl') -options[:history] = "#{history_dir}/.#{File.basename program}_history" if - File.exists? history_dir = File.expand_path(ENV['REPL_HISTORY_DIR'] || '~/') +if File.exists? completion_dir = File.expand_path(ENV['REPL_COMPLETION_DIR'] || '~/.repl') + options[:completion] = '-f ' + Dir[completion_dir + '/' + File.basename(program)].first +end -if options[:debug] - print 'rlwrap ' if ENV['__REPL_WRAPPED'] - print "-f #{options[:completion]} " if options[:completion] - print "-H #{options[:history]} " if options[:history] - puts program.inspect +if File.exists? history_dir = File.expand_path(ENV['REPL_HISTORY_DIR'] || '~/') + options[:history] = "-H #{history_dir}/.#{File.basename program}_history" end +if not ENV['__REPL_WRAPPED'] and `which rlwrap > /dev/null 2> /dev/null` + ENV['__REPL_WRAPPED'] = '0' + exec rlwrap = "rlwrap %s %s #$0 #{arguments} #{program}" % [ options[:completion], options[:history] ] +end + +puts options.to_a.map { |n| n * ' ' } * "\n" if options[:debug] + loop do print ENV['REPL_PROMPT'] || "#{ARGV[0]}>> " line = STDIN.gets.chomp - - command = options[:stdin] ? "echo '%s' | #{program}" : "#{program} %s" + system command = options[:stdin] ? "echo '#{line}' | #{program}" : "#{program} #{line}" puts "$ #{command}" if options[:debug] - - system command % [line, nil] - warn 'Use Ctrl-D to exit' if line =~ /^(exit|quit)$/ end From ee3ca612cbc6067c7267fac288e7e5e2fa514963 Mon Sep 17 00:00:00 2001 From: George Date: Tue, 23 Apr 2013 15:11:18 +0400 Subject: [PATCH 04/16] Fixing issues #14, #15, #16, #17 --- README.md | 24 ++++++++++-------------- Rakefile | 6 ++---- bin/repl | 4 ++-- repl.gemspec | 33 ++++++++++++--------------------- 4 files changed, 26 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 2262af1..32b3839 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ For example: uptime_in_days:2 .. etc .. - Or: $ repl gem @@ -38,7 +37,6 @@ Or: oortle-yajl-ruby (0.5.8) yajl-ruby (0.6.7) - Or even: $ repl git @@ -74,8 +72,7 @@ You can also use `%s` to tell repl where to stick the input: Addons: Piggyback SSL Owner: b****@*******.com - -If you have [rlwrap(1)][0] installed you'll automatically get the full +If you have [rlwrap][0] installed you'll automatically get the full benefits of readline: history, reverse searches, etc. `repl` is meant to wrap programs which accept command line arguments @@ -83,7 +80,6 @@ and print to the standard output. It keeps no state between executed lines and, as such, cannot be used to replace `irb` or the Python REPL (for example). - Install ------- @@ -91,19 +87,22 @@ Install `repl` is easily installed as a standalone script: - export REPL_BIN=~/bin/repl - curl -s https://raw.github.com/defunkt/repl/latest/bin/repl > $REPL_BIN - chmod 755 $REPL_BIN +```sh +export REPL_BIN=~/bin/repl +curl -s https://raw.github.com/defunkt/repl/latest/bin/repl > $REPL_BIN +chmod 755 $REPL_BIN +``` Change `$REPL_BIN` to your desired location and have at! (Just make sure it's in your `$PATH`.) ### RubyGems -`repl` can also be installed as a RubyGem: - - $ gem install repl +`repl` can also be installed as a gem: +```sh +gem install repl +``` Completion ---------- @@ -146,7 +145,6 @@ Once you've made your great commits: 4. Create an [Issue][2] with a link to your branch 5. That's it! - Meta ---- @@ -155,13 +153,11 @@ Meta * Bugs: * Gems: - Author ------ Chris Wanstrath :: chris@ozmm.org :: @defunkt - [0]: http://utopia.knoware.nl/~hlub/rlwrap/ [1]: http://help.github.com/forking/ [2]: https://github.com/defunkt/repl/issues diff --git a/Rakefile b/Rakefile index 9091ebe..46a105d 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,5 @@ -$LOAD_PATH.unshift 'lib' -require "repl/version" - -def version; Repl::VERSION end +Dir.chdir File.dirname __FILE__ +def version; `bin/repl -v`[/[^ ]+$/] end def git(command); `git #{command}` end desc "Build manual" diff --git a/bin/repl b/bin/repl index c53c93f..0f4cdaf 100755 --- a/bin/repl +++ b/bin/repl @@ -4,7 +4,7 @@ require 'optparse' arguments, options = ARGV.join(' '), {} OptionParser.new do |o| - o.banner = 'Usage: repl [options] command' + o.banner += ' command' o.summary_width = 15 o.version = '1.0.0' @@ -33,7 +33,7 @@ end puts options.to_a.map { |n| n * ' ' } * "\n" if options[:debug] loop do - print ENV['REPL_PROMPT'] || "#{ARGV[0]}>> " + print (ENV['REPL_PROMPT'] || '%s>> ') % ARGV[0] line = STDIN.gets.chomp system command = options[:stdin] ? "echo '#{line}' | #{program}" : "#{program} #{line}" puts "$ #{command}" if options[:debug] diff --git a/repl.gemspec b/repl.gemspec index e892476..065acc4 100644 --- a/repl.gemspec +++ b/repl.gemspec @@ -1,23 +1,14 @@ -$LOAD_PATH.unshift 'lib' -require "repl/version" - +Dir.chdir File.dirname __FILE__ Gem::Specification.new do |s| - s.name = "repl" - s.version = Repl::VERSION - s.date = Time.now.strftime('%Y-%m-%d') - s.summary = "sometimes you need a repl" - s.homepage = "http://github.com/defunkt/repl" - s.email = "chris@ozmm.org" - s.authors = [ "Chris Wanstrath" ] - s.has_rdoc = false - - s.files = %w( README.md Rakefile LICENSE ) - s.files += Dir.glob("bin/**/*") - s.files += Dir.glob("man/**/*") - - s.executables = %w( repl ) - s.description = < Date: Wed, 12 Jun 2013 03:44:54 +0400 Subject: [PATCH 05/16] Much more durable --- bin/repl | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/bin/repl b/bin/repl index 0f4cdaf..f926bf5 100755 --- a/bin/repl +++ b/bin/repl @@ -2,39 +2,45 @@ require 'optparse' %w[INT TERM].each { |s| trap(s) { abort '' } } -arguments, options = ARGV.join(' '), {} +executable = ARGV.find_index { |a| not a[/^-/] } || 0 +options, settings = ARGV.shift(executable), {} +program = ARGV.join(' ') + OptionParser.new do |o| o.banner += ' command' - o.summary_width = 15 + o.summary_width = 17 o.version = '1.0.0' - o.on('-h', '--help', 'Display this message') { puts o; exit } - o.on('-s', '--stdin', "Pipe input to command's STDIN") { options[:stdin] = true } - o.on('-d', '--debug', 'Display each command executed') { options[:debug] = true } + o.on('-s', '--stdin', "Pipe input to command's STDIN") { settings[:stdin] = true } + o.on('-d', '--debug', 'Display each command executed') { settings[:debug] = true } o.on('-m', '--man', 'Display the man page') { exec "man #{File.dirname __FILE__}/../man/repl.1" } -end.parse! - -program = ARGV.join ' ' -exec "#{$0} -h" if program.empty? +end.parse! options.dup if File.exists? completion_dir = File.expand_path(ENV['REPL_COMPLETION_DIR'] || '~/.repl') - options[:completion] = '-f ' + Dir[completion_dir + '/' + File.basename(program)].first + settings[:completion] = '-f ' + Dir[completion_dir + '/' + File.basename(program)].first end if File.exists? history_dir = File.expand_path(ENV['REPL_HISTORY_DIR'] || '~/') - options[:history] = "-H #{history_dir}/.#{File.basename program}_history" + settings[:history] = "-H #{history_dir}/.#{File.basename program}_history" end -if not ENV['__REPL_WRAPPED'] and `which rlwrap > /dev/null 2> /dev/null` +if `which rlwrap > /dev/null 2> /dev/null` and not ENV['__REPL_WRAPPED'] ENV['__REPL_WRAPPED'] = '0' - exec rlwrap = "rlwrap %s %s #$0 #{arguments} #{program}" % [ options[:completion], options[:history] ] + program.sub!(/%s?/, '%') + p program + rlwrap = "rlwrap %s %s #$0 #{options * ' '} #{program}" % [ settings[:completion], settings[:history] ] + puts rlwrap if settings[:debug] + exec rlwrap end -puts options.to_a.map { |n| n * ' ' } * "\n" if options[:debug] +puts settings.to_a.map { |n| n * ': ' } * "\n" << "\nprogram: #{program}" if settings[:debug] +program.sub!(/%s?/i, '%s') loop do - print (ENV['REPL_PROMPT'] || '%s>> ') % ARGV[0] + print ENV['REPL_PROMPT'] || '%s>> ' % ARGV[0] line = STDIN.gets.chomp - system command = options[:stdin] ? "echo '#{line}' | #{program}" : "#{program} #{line}" - puts "$ #{command}" if options[:debug] + command = settings[:stdin] ? + "echo \"%s\" | #{program}" : "#{program} %s" + puts "$ #{command}" if settings[:debug] + system command end From 7eb8d8a5caf81e3a0c3af8a524baf7faed046ad1 Mon Sep 17 00:00:00 2001 From: George Date: Wed, 24 Jul 2013 07:00:00 +0400 Subject: [PATCH 06/16] Now it works --- bin/repl | 44 ++++++++++++++++++++++++-------------------- man/repl.1.ronn | 8 ++++---- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/bin/repl b/bin/repl index f926bf5..89dfdc7 100755 --- a/bin/repl +++ b/bin/repl @@ -2,9 +2,15 @@ require 'optparse' %w[INT TERM].each { |s| trap(s) { abort '' } } -executable = ARGV.find_index { |a| not a[/^-/] } || 0 -options, settings = ARGV.shift(executable), {} +executable = ARGV.find_index { |a| not a[/^-/] } + +options = executable ? ARGV.shift(executable) : ARGV program = ARGV.join(' ') +settings = {} + +# If nothing but options specified, or nothing +# at all, show some help information. +options << %w[-h] unless executable OptionParser.new do |o| o.banner += ' command' @@ -14,33 +20,31 @@ OptionParser.new do |o| o.on('-s', '--stdin', "Pipe input to command's STDIN") { settings[:stdin] = true } o.on('-d', '--debug', 'Display each command executed') { settings[:debug] = true } o.on('-m', '--man', 'Display the man page') { exec "man #{File.dirname __FILE__}/../man/repl.1" } -end.parse! options.dup +end.parse(options) -if File.exists? completion_dir = File.expand_path(ENV['REPL_COMPLETION_DIR'] || '~/.repl') - settings[:completion] = '-f ' + Dir[completion_dir + '/' + File.basename(program)].first -end +name = program.gsub('%s', '').gsub(/\W/, '') -if File.exists? history_dir = File.expand_path(ENV['REPL_HISTORY_DIR'] || '~/') - settings[:history] = "-H #{history_dir}/.#{File.basename program}_history" -end +completion_dir = File.expand_path(ENV['REPL_COMPLETION_DIR'] || '~/.repl') +history_dir = File.expand_path(ENV['REPL_HISTORY_DIR'] || '~/') + +settings[:completion] = "-f #{completion_dir}/#{name}" if File.exists? completion_dir +settings[:history] = "-H #{history_dir}/.#{name}_history" if File.exists? history_dir -if `which rlwrap > /dev/null 2> /dev/null` and not ENV['__REPL_WRAPPED'] +if `which rlwrap 1>&2> /dev/null` && !ENV['__REPL_WRAPPED'] ENV['__REPL_WRAPPED'] = '0' - program.sub!(/%s?/, '%') - p program - rlwrap = "rlwrap %s %s #$0 #{options * ' '} #{program}" % [ settings[:completion], settings[:history] ] - puts rlwrap if settings[:debug] + rlwrap = ['rlwrap', settings[:completion], settings[:history], $0, options.join(' '), program] * ' ' + puts '> ' + rlwrap if settings[:debug] exec rlwrap end -puts settings.to_a.map { |n| n * ': ' } * "\n" << "\nprogram: #{program}" if settings[:debug] -program.sub!(/%s?/i, '%s') +puts settings.to_a.map { |n| "" } * "\n" << "\n> program: #{program}" if settings[:debug] + +prompt = prompt = ENV['REPL_PROMPT'] ? prompt.sub('%s', ARGV.first) : '%s>> ' % ARGV.first +pattern = settings[:stdin] ? "echo \"%s\" | #{program}" : "#{program} %s" loop do - print ENV['REPL_PROMPT'] || '%s>> ' % ARGV[0] - line = STDIN.gets.chomp - command = settings[:stdin] ? - "echo \"%s\" | #{program}" : "#{program} %s" + print prompt + command = pattern % [STDIN.gets.chomp, nil] puts "$ #{command}" if settings[:debug] system command end diff --git a/man/repl.1.ronn b/man/repl.1.ronn index d92cae2..4dd35da 100644 --- a/man/repl.1.ronn +++ b/man/repl.1.ronn @@ -3,7 +3,7 @@ repl(1) - sometimes you need a repl ## SYNOPSIS -`repl` <[repl-options]> <...> +`repl` <[options]> <...> ## DESCRIPTION @@ -82,13 +82,13 @@ Using `repl` with `git`: * `-h`, `--help`: Displays usage information. - * `--stdin`: + * `-s`, `--stdin`: Pipe input to command's STDIN. - * `--debug`: + * `-d`, `--debug`: Displays debug information while running. - * `--man`: + * `-m`, `--man`: Displays this man page. ## COMPLETION From 298640d455328b54510daf2ede1212d15d9e3c15 Mon Sep 17 00:00:00 2001 From: George Date: Wed, 24 Jul 2013 07:05:37 +0400 Subject: [PATCH 07/16] =?UTF-8?q?Finishing=20touch=20(~/=20=E2=86=92=20~)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/repl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/repl b/bin/repl index 89dfdc7..bcd71cf 100755 --- a/bin/repl +++ b/bin/repl @@ -25,7 +25,7 @@ end.parse(options) name = program.gsub('%s', '').gsub(/\W/, '') completion_dir = File.expand_path(ENV['REPL_COMPLETION_DIR'] || '~/.repl') -history_dir = File.expand_path(ENV['REPL_HISTORY_DIR'] || '~/') +history_dir = File.expand_path(ENV['REPL_HISTORY_DIR'] || '~') settings[:completion] = "-f #{completion_dir}/#{name}" if File.exists? completion_dir settings[:history] = "-H #{history_dir}/.#{name}_history" if File.exists? history_dir @@ -33,11 +33,11 @@ settings[:history] = "-H #{history_dir}/.#{name}_history" if File.exists? histor if `which rlwrap 1>&2> /dev/null` && !ENV['__REPL_WRAPPED'] ENV['__REPL_WRAPPED'] = '0' rlwrap = ['rlwrap', settings[:completion], settings[:history], $0, options.join(' '), program] * ' ' - puts '> ' + rlwrap if settings[:debug] + puts rlwrap if settings[:debug] exec rlwrap end -puts settings.to_a.map { |n| "" } * "\n" << "\n> program: #{program}" if settings[:debug] +puts settings.to_a.map { |n| n * ': ' } * "\n" << "\nprogram: #{program}" if settings[:debug] prompt = prompt = ENV['REPL_PROMPT'] ? prompt.sub('%s', ARGV.first) : '%s>> ' % ARGV.first pattern = settings[:stdin] ? "echo \"%s\" | #{program}" : "#{program} %s" From 5cf8a434515fa269674681cee970ce72c5b5dbdc Mon Sep 17 00:00:00 2001 From: George Date: Wed, 24 Jul 2013 07:36:33 +0400 Subject: [PATCH 08/16] Minor documentation changes --- bin/repl | 2 +- man/repl.1.ronn | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/repl b/bin/repl index bcd71cf..2241345 100755 --- a/bin/repl +++ b/bin/repl @@ -9,7 +9,7 @@ program = ARGV.join(' ') settings = {} # If nothing but options specified, or nothing -# at all, show some help information. +# specified at all, show some help information: options << %w[-h] unless executable OptionParser.new do |o| diff --git a/man/repl.1.ronn b/man/repl.1.ronn index 4dd35da..f2823bc 100644 --- a/man/repl.1.ronn +++ b/man/repl.1.ronn @@ -1,9 +1,9 @@ -repl(1) - sometimes you need a repl -=================================== +repl(1) - read-eval-print-loop wrapper +====================================== ## SYNOPSIS -`repl` <[options]> <...> +`repl` [options] ## DESCRIPTION @@ -33,7 +33,6 @@ Using `repl` with `redis-cli`: redis_version:1.000 uptime_in_seconds:182991 uptime_in_days:2 - .. etc .. Using `repl` with Ruby's `gem`: @@ -60,18 +59,18 @@ Using `repl` with Ruby's `gem`: Using `repl` with `git`: $ repl git - >> branch + git>> branch gh-pages * master - >> tag + git>> tag rm v0.1.0 v0.1.1 v0.1.2 v0.1.3 - >> tag -d rm + git>> tag -d rm Deleted tag 'rm' - >> pwd + git>> pwd git: 'pwd' is not a git-command. See 'git --help'. Did you mean this? @@ -122,7 +121,8 @@ The directory searched for history files can be configured using the ### REPL_PROMPT -the prompt to display before each line of input. defaults to >> +the prompt to display before each line of input. defaults to %s>>. +%s is for the program name ### REPL_COMPLETION_DIR From f5a60a34821edcc63d3a14e260cbcc229db926ae Mon Sep 17 00:00:00 2001 From: George Date: Wed, 24 Jul 2013 07:38:30 +0400 Subject: [PATCH 09/16] =?UTF-8?q?Revert=20=E2=80=9Ccleaning=E2=80=9D=20Rak?= =?UTF-8?q?efile=20(I=20suppose=20I=20was=20drunk=20that=20night)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rakefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 46a105d..8eaed4b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,12 @@ -Dir.chdir File.dirname __FILE__ -def version; `bin/repl -v`[/[^ ]+$/] end -def git(command); `git #{command}` end +Dir.chdir File.dirname(__FILE__) + +def version + `bin/repl -v`[/[^ ]+$/] +end + +def git(command) + sh "git #{command}" +end desc "Build manual" task :build_man do From f139b18e275259d2a217732dd24a4dccb1cfee6e Mon Sep 17 00:00:00 2001 From: George Date: Wed, 24 Jul 2013 07:47:39 +0400 Subject: [PATCH 10/16] Fresh documentation --- README.md | 34 +++++++++++++++++++--------------- man/repl.1.ronn | 12 ++++++------ 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 32b3839..d636f37 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ -repl(1) -- sometimes you need a repl -==================================== +repl +==== + +Sometimes you need a REPL +------------------------- `repl` is an interactive program which tenderly wraps another, non-interactive program. @@ -7,27 +10,26 @@ non-interactive program. For example: $ repl redis-cli -p 6665 - >> set name chris + redis-cli>> set name chris OK - >> get name + redis-cli>> get name chris - >> info + redis-cli>> info redis_version:1.000 uptime_in_seconds:182991 uptime_in_days:2 - .. etc .. Or: $ repl gem - >> --version + gem>> --version 1.3.5 - >> search yajl + gem>> search yajl *** LOCAL GEMS *** yajl-ruby (0.6.7) - >> search yajl -r + gem>> search yajl -r *** REMOTE GEMS *** @@ -40,18 +42,18 @@ Or: Or even: $ repl git - >> branch + git>> branch gh-pages * master - >> tag + git>> tag rm v0.1.0 v0.1.1 v0.1.2 v0.1.3 - >> tag -d rm + git>> tag -d rm Deleted tag 'rm' - >> pwd + git>> pwd git: 'pwd' is not a git-command. See 'git --help'. Did you mean this? @@ -60,7 +62,7 @@ Or even: You can also use `%s` to tell repl where to stick the input: $ repl heroku %s --app domainy - >> info + heroku>> info === domainy Web URL: http://domainy.heroku.com/ Git Repo: git@heroku.com:domainy.git @@ -128,11 +130,13 @@ Configuration The following environment variables affect `repl`'s behavior: `REPL_PROMPT`: - the prompt to display before each line of input. defaults to >> + the prompt to display before each line of input. defaults to %s>> `REPL_COMPLETION_DIR`: directory in which completion files are kept +`REPL_HISTORY_DIR`: + directory in which command history files are kept Contributing ------------ diff --git a/man/repl.1.ronn b/man/repl.1.ronn index f2823bc..57150e2 100644 --- a/man/repl.1.ronn +++ b/man/repl.1.ronn @@ -25,11 +25,11 @@ REPL (for example). Using `repl` with `redis-cli`: $ repl redis-cli - >> set name chris + redis-cli>> set name chris OK - >> get name + redis-cli>> get name chris - >> info + redis-cli>> info redis_version:1.000 uptime_in_seconds:182991 uptime_in_days:2 @@ -38,14 +38,14 @@ Using `repl` with `redis-cli`: Using `repl` with Ruby's `gem`: $ repl gem - >> --version + gem>> --version 1.3.5 - >> search yajl + gem>> search yajl *** LOCAL GEMS *** yajl-ruby (0.6.7) - >> search yajl -r + gem>> search yajl -r *** REMOTE GEMS *** From e520612bf0ca1909e29b6d9df6504528efa5f691 Mon Sep 17 00:00:00 2001 From: George Date: Wed, 24 Jul 2013 08:01:08 +0400 Subject: [PATCH 11/16] Minor refactoring --- bin/repl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/repl b/bin/repl index 2241345..a2e95f1 100755 --- a/bin/repl +++ b/bin/repl @@ -1,6 +1,5 @@ #!/usr/bin/env ruby require 'optparse' -%w[INT TERM].each { |s| trap(s) { abort '' } } executable = ARGV.find_index { |a| not a[/^-/] } @@ -39,9 +38,10 @@ end puts settings.to_a.map { |n| n * ': ' } * "\n" << "\nprogram: #{program}" if settings[:debug] -prompt = prompt = ENV['REPL_PROMPT'] ? prompt.sub('%s', ARGV.first) : '%s>> ' % ARGV.first +prompt = (ENV['REPL_PROMPT'] || '%s>> ') % ARGV.first pattern = settings[:stdin] ? "echo \"%s\" | #{program}" : "#{program} %s" +%w[INT TERM].each { |s| trap(s) { abort '' } } loop do print prompt command = pattern % [STDIN.gets.chomp, nil] From 5218c27fea506ab90ad53f3a6c69ac6e90db3752 Mon Sep 17 00:00:00 2001 From: George Date: Wed, 24 Jul 2013 16:59:10 +0545 Subject: [PATCH 12/16] Rebuild man --- man/repl.1 | 116 +++++++++++--------------- man/repl.1.html | 214 +++++++++++++++++++++++++----------------------- man/repl.1.ronn | 2 +- 3 files changed, 164 insertions(+), 168 deletions(-) diff --git a/man/repl.1 b/man/repl.1 index c42ff86..b46e612 100644 --- a/man/repl.1 +++ b/man/repl.1 @@ -1,29 +1,22 @@ -.\" generated with Ronn/v0.5 -.\" http://github.com/rtomayko/ronn/ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "REPL" "1" "May 2010" "DEFUNKT" "" +.TH "REPL" "1" "July 2013" "DEFUNKT" "" . .SH "NAME" -\fBrepl\fR \-\- sometimes you need a repl +\fBrepl\fR \- read\-eval\-print\-loop wrapper . .SH "SYNOPSIS" -\fBrepl\fR \fI[repl\-options]\fR \fIcommand\fR <...> +\fBrepl\fR [\fIoptions\fR] \fIcommand\fR . .SH "DESCRIPTION" -\fBrepl\fR wraps a non\-interactive \fBcommand\fR in an interactive -read\-eval\-print\-loop prompt. Each line you type into the prompt is -executed as arguments to \fBcommand\fR. Anything written to standard -output or standard error by the \fBcommand\fR is displayed. +\fBrepl\fR wraps a non\-interactive \fBcommand\fR in an interactive read\-eval\-print\-loop prompt\. Each line you type into the prompt is executed as arguments to \fBcommand\fR\. Anything written to standard output or standard error by the \fBcommand\fR is displayed\. . .P -If you have \fBrlwrap(1)\fR installed you'll automatically get the full -benefits of readline: history, reverse searches, etc. +If you have \fBrlwrap(1)\fR installed you\'ll automatically get the full benefits of readline: history, reverse searches, etc\. . .P -\fBrepl\fR is meant to wrap programs which accept command line arguments -and print to the standard output. It keeps no state between executed -lines and, as such, cannot be used to replace \fBirb\fR or the Python -REPL (for example). +\fBrepl\fR is meant to wrap programs which accept command line arguments and print to the standard output\. It keeps no state between executed lines and, as such, cannot be used to replace \fBirb\fR or the Python REPL (for example)\. . .SH "EXAMPLES" Using \fBrepl\fR with \fBredis\-cli\fR: @@ -33,44 +26,43 @@ Using \fBrepl\fR with \fBredis\-cli\fR: .nf $ repl redis\-cli ->> set name chris +redis\-cli>> set name chris OK ->> get name +redis\-cli>> get name chris ->> info -redis_version:1.000 +redis\-cli>> info +redis_version:1\.000 uptime_in_seconds:182991 uptime_in_days:2 -.. etc .. . .fi . .IP "" 0 . .P -Using \fBrepl\fR with Ruby's \fBgem\fR: +Using \fBrepl\fR with Ruby\'s \fBgem\fR: . .IP "" 4 . .nf $ repl gem ->> \-\-version -1.3.5 ->> search yajl +gem>> \-\-version +1\.3\.5 +gem>> search yajl *** LOCAL GEMS *** -yajl\-ruby (0.6.7) ->> search yajl \-r +yajl\-ruby (0\.6\.7) +gem>> search yajl \-r *** REMOTE GEMS *** -brianmario\-yajl\-ruby (0.6.3) -filipegiusti\-yajl\-ruby (0.6.4) -jdg\-yajl\-ruby (0.5.12) -oortle\-yajl\-ruby (0.5.8) -yajl\-ruby (0.6.7) +brianmario\-yajl\-ruby (0\.6\.3) +filipegiusti\-yajl\-ruby (0\.6\.4) +jdg\-yajl\-ruby (0\.5\.12) +oortle\-yajl\-ruby (0\.5\.8) +yajl\-ruby (0\.6\.7) . .fi . @@ -84,19 +76,19 @@ Using \fBrepl\fR with \fBgit\fR: .nf $ repl git ->> branch +git>> branch gh\-pages * master ->> tag +git>> tag rm -v0.1.0 -v0.1.1 -v0.1.2 -v0.1.3 ->> tag \-d rm -Deleted tag 'rm' ->> pwd -git: 'pwd' is not a git\-command. See 'git \-\-help'. +v0\.1\.0 +v0\.1\.1 +v0\.1\.2 +v0\.1\.3 +git>> tag \-d rm +Deleted tag \'rm\' +git>> pwd +git: \'pwd\' is not a git\-command\. See \'git \-\-help\'\. Did you mean this? add @@ -109,50 +101,42 @@ Did you mean this? . .TP \fB\-h\fR, \fB\-\-help\fR -Displays usage information. +Displays usage information\. . .TP -\fB\-\-stdin\fR -Pipe input to command's STDIN. +\fB\-s\fR, \fB\-\-stdin\fR +Pipe input to command\'s STDIN\. . .TP -\fB\-\-debug\fR -Displays debug information while running. +\fB\-d\fR, \fB\-\-debug\fR +Displays debug information while running\. . .TP -\fB\-\-man\fR -Displays this man page. +\fB\-m\fR, \fB\-\-man\fR +Displays this man page\. . .SH "COMPLETION" -Because \fBrlwrap\fR supports completion, \fBrepl\fR does too. Any file in \fB~/.repl\fR matching the name of the command you start \fBrepl\fR with will -be used for completion. +Because \fBrlwrap\fR supports completion, \fBrepl\fR does too\. Any file in \fB~/\.repl\fR matching the name of the command you start \fBrepl\fR with will be used for completion\. . .P -For instance, a file named \fB~/.repl/redis\-cli\fR containing "get set -info" will cause "get", "set", and "info" to be tab completeable at -the \fBrepl redis\-cli\fR prompt. +For instance, a file named \fB~/\.repl/redis\-cli\fR containing "get set info" will cause "get", "set", and "info" to be tab completeable at the \fBrepl redis\-cli\fR prompt\. . .P -The directory searched for completion files can be configured using -the \fBREPL_COMPLETION_DIR\fR environment variable. +The directory searched for completion files can be configured using the \fBREPL_COMPLETION_DIR\fR environment variable\. . .SH "COMMAND HISTORY" -Because \fBrlwrap\fR supports command history, \fBrepl\fR does too. Any file in \fB~/\fR matching the name of the command you start \fBrepl\fR with prefix -with a dot and suffixed with "_history" will be used for completion. +Because \fBrlwrap\fR supports command history, \fBrepl\fR does too\. Any file in \fB~/\fR matching the name of the command you start \fBrepl\fR with prefix with a dot and suffixed with "_history" will be used for completion\. . .P -For instance, a file named \fB~/.redis\-cli_history\fR containing a newline -separated list of "get set info" will cause "get", "set", and "info" -to be reachable using the up arrow as command history at the \fBrepl -redis\-cli\fR prompt. +For instance, a file named \fB~/\.redis\-cli_history\fR containing a newline separated list of "get set info" will cause "get", "set", and "info" to be reachable using the up arrow as command history at the \fBrepl redis\-cli\fR prompt\. . .P -The directory searched for history files can be configured using the \fBREPL_HISTORY_DIR\fR environment variable. +The directory searched for history files can be configured using the \fBREPL_HISTORY_DIR\fR environment variable\. . .SH "ENVIRONMENT" . .SS "REPL_PROMPT" -the prompt to display before each line of input. defaults to >> +the prompt to display before each line of input\. defaults to %s>>\. %s is for the program name . .SS "REPL_COMPLETION_DIR" directory in which completion files are kept @@ -161,10 +145,10 @@ directory in which completion files are kept directory in which command history files are kept . .SH "BUGS" -\fIhttp://github.com/defunkt/repl/issues\fR +\fIhttp://github\.com/defunkt/repl/issues\fR . .SH "AUTHOR" -Chris Wanstrath :: chris@ozmm.org :: @defunkt +Chris Wanstrath :: chris@ozmm\.org :: @defunkt . .SH "SEE ALSO" -rlwrap(1), readline(3), \fIhttp://github.com\fR, \fIhttp://github.com/defunkt/repl\fR +rlwrap(1), readline(3), \fIhttp://github\.com\fR, \fIhttp://github\.com/defunkt/repl\fR diff --git a/man/repl.1.html b/man/repl.1.html index 42abc24..99e0816 100644 --- a/man/repl.1.html +++ b/man/repl.1.html @@ -2,74 +2,86 @@ - - repl(1) -- sometimes you need a repl - - -
- -

repl(1)

- -
    -
  1. repl(1)
  2. -
  3. -
  4. repl(1)
  5. -
- -

NAME

-

repl -- sometimes you need a repl

- -

SYNOPSIS

- -

repl [repl-options] command <...>

- -

DESCRIPTION

+ + +
+ + + +
    +
  1. repl(1)
  2. +
  3. +
  4. repl(1)
  5. +
+ +

NAME

+

+ repl - read-eval-print-loop wrapper +

+ +

SYNOPSIS

+ +

repl [options] command

+ +

DESCRIPTION

repl wraps a non-interactive command in an interactive read-eval-print-loop prompt. Each line you type into the prompt is @@ -84,33 +96,32 @@

DESCRIPTION

lines and, as such, cannot be used to replace irb or the Python REPL (for example).

-

EXAMPLES

+

EXAMPLES

Using repl with redis-cli:

$ repl redis-cli
->> set name chris
+redis-cli>> set name chris
 OK
->> get name
+redis-cli>> get name
 chris
->> info
+redis-cli>> info
 redis_version:1.000
 uptime_in_seconds:182991
 uptime_in_days:2
-.. etc ..
 

Using repl with Ruby's gem:

$ repl gem
->> --version
+gem>> --version
 1.3.5
->> search yajl
+gem>> search yajl
 
 *** LOCAL GEMS ***
 
 yajl-ruby (0.6.7)
->> search yajl -r
+gem>> search yajl -r
 
 *** REMOTE GEMS ***
 
@@ -124,35 +135,35 @@ 

EXAMPLES

Using repl with git:

$ repl git
->> branch
+git>> branch
   gh-pages
 * master
->> tag
+git>> tag
 rm
 v0.1.0
 v0.1.1
 v0.1.2
 v0.1.3
->> tag -d rm
+git>> tag -d rm
 Deleted tag 'rm'
->> pwd
+git>> pwd
 git: 'pwd' is not a git-command. See 'git --help'.
 
 Did you mean this?
   add
 
-

OPTIONS

+

OPTIONS

-h, --help

Displays usage information.

-
--stdin

Pipe input to command's STDIN.

-
--debug

Displays debug information while running.

-
--man

Displays this man page.

+
-s, --stdin

Pipe input to command's STDIN.

+
-d, --debug

Displays debug information while running.

+
-m, --man

Displays this man page.

-

COMPLETION

+

COMPLETION

Because rlwrap supports completion, repl does too. Any file in ~/.repl matching the name of the command you start repl with will @@ -165,7 +176,7 @@

COMPLETION

The directory searched for completion files can be configured using the REPL_COMPLETION_DIR environment variable.

-

COMMAND HISTORY

+

COMMAND HISTORY

Because rlwrap supports command history, repl does too. Any file in ~/ matching the name of the command you start repl with prefix @@ -179,40 +190,41 @@

COMMAND HISTORY

The directory searched for history files can be configured using the REPL_HISTORY_DIR environment variable.

-

ENVIRONMENT

+

ENVIRONMENT

-

REPL_PROMPT

+

REPL_PROMPT

-

the prompt to display before each line of input. defaults to >>

+

the prompt to display before each line of input. defaults to %s>>. +%s is for the program name

-

REPL_COMPLETION_DIR

+

REPL_COMPLETION_DIR

directory in which completion files are kept

-

REPL_HISTORY_DIR

+

REPL_HISTORY_DIR

directory in which command history files are kept

-

BUGS

+

BUGS

-

http://github.com/defunkt/repl/issues

+

http://github.com/defunkt/repl/issues

-

AUTHOR

+

AUTHOR

Chris Wanstrath :: chris@ozmm.org :: @defunkt

-

SEE ALSO

+

SEE ALSO

-

rlwrap(1), readline(3), http://github.com, -http://github.com/defunkt/repl

+

rlwrap(1), readline(3), http://github.com, +http://github.com/defunkt/repl

-
    -
  1. DEFUNKT
  2. -
  3. May 2010
  4. -
  5. repl(1)
  6. -
+
    +
  1. DEFUNKT
  2. +
  3. July 2013
  4. +
  5. repl(1)
  6. +
-
+
diff --git a/man/repl.1.ronn b/man/repl.1.ronn index 57150e2..6051603 100644 --- a/man/repl.1.ronn +++ b/man/repl.1.ronn @@ -3,7 +3,7 @@ repl(1) - read-eval-print-loop wrapper ## SYNOPSIS -`repl` [options] +`repl` [] ## DESCRIPTION From 9665c544501060b41640fe20487b1a8f93b6f819 Mon Sep 17 00:00:00 2001 From: George Date: Wed, 24 Jul 2013 17:57:35 +0545 Subject: [PATCH 13/16] -v flag and fixed gemspec --- README.md | 5 +---- Rakefile | 39 ++++++++++++++++++--------------------- bin/repl | 4 ++-- man/repl.1 | 4 ++++ man/repl.1.html | 1 + man/repl.1.ronn | 3 +++ repl.gemspec | 18 ++++++++++-------- 7 files changed, 39 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index d636f37..8098a70 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ -repl +REPL ==== -Sometimes you need a REPL -------------------------- - `repl` is an interactive program which tenderly wraps another, non-interactive program. diff --git a/Rakefile b/Rakefile index 8eaed4b..5eaeb8c 100644 --- a/Rakefile +++ b/Rakefile @@ -1,42 +1,39 @@ Dir.chdir File.dirname(__FILE__) - -def version - `bin/repl -v`[/[^ ]+$/] -end +version = `bin/repl -v`[/\d+\.\d+\.\d+/] def git(command) sh "git #{command}" end -desc "Build manual" +desc 'Build manual' task :build_man do - sh "ronn -br5 --organization=DEFUNKT man/*.ronn" + sh 'ronn -br5 --organization=DEFUNKT man/*.ronn' end -desc "Build and show manual" +desc 'Build and show manual' task :man => :build_man do - exec "man man/repl.1" + exec 'man man/repl.1' end -desc "Push a new version to Gemcutter" +desc 'Push a new version to Gemcutter' task :publish do git "tag v#{version}" git "push origin v#{version}" - git "push origin master" - git "push origin master:latest" - sh "gem build repl.gemspec" + git 'push origin master' + git 'push origin master:latest' + sh 'gem build repl.gemspec' sh "gem push repl-#{version}.gem" - git "clean -fd" - exec "rake pages" + git 'clean -fd' + exec 'rake pages' end -desc "Publish to GitHub Pages" -task :pages => [:build_man] do - cp "man/repl.1.html", "html" - git "checkout gh-pages" - mv "html", "index.html" +desc 'Publish to GitHub Pages' +task :pages => :build_man do + cp 'man/repl.1.html', 'html' + git 'checkout gh-pages' + mv 'html', 'index.html' git "commit -a -m 'update docs'" - git "push origin gh-pages" - git "checkout master" + git 'push origin gh-pages' + git 'checkout master' puts :done end diff --git a/bin/repl b/bin/repl index a2e95f1..815bafc 100755 --- a/bin/repl +++ b/bin/repl @@ -14,14 +14,14 @@ options << %w[-h] unless executable OptionParser.new do |o| o.banner += ' command' o.summary_width = 17 - o.version = '1.0.0' o.on('-h', '--help', 'Display this message') { puts o; exit } o.on('-s', '--stdin', "Pipe input to command's STDIN") { settings[:stdin] = true } o.on('-d', '--debug', 'Display each command executed') { settings[:debug] = true } o.on('-m', '--man', 'Display the man page') { exec "man #{File.dirname __FILE__}/../man/repl.1" } + o.on('-v', '--version', 'Print REPL version') { puts 'REPL 1.0.0'; exit } end.parse(options) -name = program.gsub('%s', '').gsub(/\W/, '') +name = program.sub('%s', '').gsub(/\W/, '') completion_dir = File.expand_path(ENV['REPL_COMPLETION_DIR'] || '~/.repl') history_dir = File.expand_path(ENV['REPL_HISTORY_DIR'] || '~') diff --git a/man/repl.1 b/man/repl.1 index b46e612..7c44756 100644 --- a/man/repl.1 +++ b/man/repl.1 @@ -115,6 +115,10 @@ Displays debug information while running\. \fB\-m\fR, \fB\-\-man\fR Displays this man page\. . +.TP +\fB\-v\fR, \fB\-\-version\fR +Prints REPL version\. +. .SH "COMPLETION" Because \fBrlwrap\fR supports completion, \fBrepl\fR does too\. Any file in \fB~/\.repl\fR matching the name of the command you start \fBrepl\fR with will be used for completion\. . diff --git a/man/repl.1.html b/man/repl.1.html index 99e0816..acc6478 100644 --- a/man/repl.1.html +++ b/man/repl.1.html @@ -160,6 +160,7 @@

OPTIONS

-s, --stdin

Pipe input to command's STDIN.

-d, --debug

Displays debug information while running.

-m, --man

Displays this man page.

+
-v, --version

Prints REPL version.

diff --git a/man/repl.1.ronn b/man/repl.1.ronn index 6051603..5572822 100644 --- a/man/repl.1.ronn +++ b/man/repl.1.ronn @@ -90,6 +90,9 @@ Using `repl` with `git`: * `-m`, `--man`: Displays this man page. + * `-v`, `--version`: + Prints REPL version. + ## COMPLETION Because `rlwrap` supports completion, `repl` does too. Any file in diff --git a/repl.gemspec b/repl.gemspec index 065acc4..d68e2fa 100644 --- a/repl.gemspec +++ b/repl.gemspec @@ -1,14 +1,16 @@ -Dir.chdir File.dirname __FILE__ +Dir.chdir File.dirname(__FILE__) + Gem::Specification.new do |s| - s.name = "repl" - s.version = `bin/repl -v`[/[^ ]+$/] - s.date = Time.now.strftime '%Y-%m-%d' - s.summary = "sometimes you need a repl" - s.homepage = "http://github.com/defunkt/repl" - s.email = "chris@ozmm.org" - s.authors = ['Chris Wanstrath'] + s.name = 'repl' + s.version = `bin/repl -v`[/\d+\.\d+\.\d+/] + s.has_rdoc = false s.files = `git ls-files`.split("\n") s.executables = %w[repl] + + s.summary = 'Sometimes you need a REPL' s.description = 'repl is an interactive program which tenderly wraps another, non-interactive program, providing you with a repl shell.' + s.homepage = 'http://github.com/defunkt/repl' + s.email = 'chris@ozmm.org' + s.authors = 'Chris Wanstrath' end From 34221e844926509048032ad6f61bc0311a74a328 Mon Sep 17 00:00:00 2001 From: George Date: Wed, 24 Jul 2013 18:00:56 +0545 Subject: [PATCH 14/16] Gemcutter is Rubygems today --- README.md | 2 +- Rakefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8098a70..1ff6596 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ Meta * Code: `git clone git://github.com/defunkt/repl.git` * Home: * Bugs: -* Gems: +* Gems: Author ------ diff --git a/Rakefile b/Rakefile index 5eaeb8c..72a57e5 100644 --- a/Rakefile +++ b/Rakefile @@ -15,7 +15,7 @@ task :man => :build_man do exec 'man man/repl.1' end -desc 'Push a new version to Gemcutter' +desc 'Push a new version to Rubygems' task :publish do git "tag v#{version}" git "push origin v#{version}" From 46cf36147392de03fd1481db19305edc04c5efca Mon Sep 17 00:00:00 2001 From: George Date: Wed, 24 Jul 2013 19:46:20 +0545 Subject: [PATCH 15/16] Makefile, better -m, --man handling, more standalone options --- Makefile | 9 +++++++++ README.md | 28 ++++++++++++++++++---------- bin/repl | 3 ++- 3 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6416156 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +MAN=$$(head -1 /etc/manpaths) + +install: + cp bin/repl /usr/bin/repl + cp man/repl.1 $(MAN)/man1/ + +uninstall: + rm /usr/bin/repl + rm $(MAN)/man1/repl.1 diff --git a/README.md b/README.md index 1ff6596..86f6184 100644 --- a/README.md +++ b/README.md @@ -82,25 +82,33 @@ REPL (for example). Install ------- -### Standalone +### Rubygems -`repl` is easily installed as a standalone script: +`repl` can be installed as a gem: ```sh -export REPL_BIN=~/bin/repl -curl -s https://raw.github.com/defunkt/repl/latest/bin/repl > $REPL_BIN -chmod 755 $REPL_BIN +gem install repl ``` -Change `$REPL_BIN` to your desired location and have at! (Just make -sure it's in your `$PATH`.) +### Make + +Download this repo, and then just `make` your installation: -### RubyGems +```sh +cd repl-master +sudo make +``` -`repl` can also be installed as a gem: +To uninstall, use `sudo make uninstall`. + +### Curl + +You can install REPL without downloading the whole repo. This way: ```sh -gem install repl +curl -s https://raw.github.com/defunkt/repl/master/bin/repl > /usr/bin/repl +curl -s https://raw.github.com/defunkt/repl/master/man/repl.1 > /usr/local/share/man/man1/repl.1 +chmod +x /usr/bin/repl ``` Completion diff --git a/bin/repl b/bin/repl index 815bafc..8eb7f55 100755 --- a/bin/repl +++ b/bin/repl @@ -2,6 +2,7 @@ require 'optparse' executable = ARGV.find_index { |a| not a[/^-/] } +man = File.dirname(__FILE__) + '/../man/repl.1' options = executable ? ARGV.shift(executable) : ARGV program = ARGV.join(' ') @@ -17,7 +18,7 @@ OptionParser.new do |o| o.on('-h', '--help', 'Display this message') { puts o; exit } o.on('-s', '--stdin', "Pipe input to command's STDIN") { settings[:stdin] = true } o.on('-d', '--debug', 'Display each command executed') { settings[:debug] = true } - o.on('-m', '--man', 'Display the man page') { exec "man #{File.dirname __FILE__}/../man/repl.1" } + o.on('-m', '--man', 'Display the man page') { exec File.exists?(man) ? "man #{man}" : 'man repl' } o.on('-v', '--version', 'Print REPL version') { puts 'REPL 1.0.0'; exit } end.parse(options) From 9e6793d6235140d0865ebd4b6feac7748c30eebe Mon Sep 17 00:00:00 2001 From: George Date: Thu, 25 Jul 2013 10:40:37 +0545 Subject: [PATCH 16/16] Restyling the license back --- "LICENS\320\225" | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git "a/LICENS\320\225" "b/LICENS\320\225" index da97908..2745bcc 100644 --- "a/LICENS\320\225" +++ "b/LICENS\320\225" @@ -1,22 +1,20 @@ -Copyright © 2009 Chris Wanstrath +Copyright (c) 2009 Chris Wanstrath -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -The software is provided “as is”, without warranty of any kind, -express or implied, including but not limited to the warranties -of merchantability, fitness for a particular purpose and -noninfrigement. In no event shall the authors or copyright -holders be liable for any claim, damages or other liability, -whether in an action of contract, tort or otherwise, arising -from, out of or in connection with the software or the use or -other dealings in the software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.