Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# replace HERE interactive, execute command.
# for example: ruby interactive.rb expr HERE + HERE + HERE
require 'readline'
require 'shellwords'
HERE = /HERE/
def read_input
Readline.readline("> ", true)
end
command_template = ARGV
loop {
command = command_template.clone
command.map!{|fragment|
fragment.gsub(HERE) {
puts "command: #{command.join(' ')}"
read_input
}
}
puts "execute #{command.join(' ')}? (y/N)"
next unless read_input == 'y'
system *command
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.