Created
December 28, 2016 03:27
-
-
Save hitode909/40c7c46019df45e23ff665cdf8b1ba09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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