Skip to content

Instantly share code, notes, and snippets.

@marekjelen
Created June 30, 2012 17:05
Show Gist options
  • Save marekjelen/3024635 to your computer and use it in GitHub Desktop.
Save marekjelen/3024635 to your computer and use it in GitHub Desktop.
Presentation demos automator
- description: Provide a description of command you need to run and have it run
command: sleep 1; echo "a"; sleep 2; echo "b"
clear: true
- description: And when the program failes, you will be notified
command: exit 1
#!/usr/bin/env ruby
require 'yaml'
program = YAML.load_file(ARGV[0] + ".yml")
def continue?
puts
print "\033[1;37m"
print "continue?"
$stdin.gets
puts
end
def run_and_print(command)
print "\033[1;34m"
puts command
print "\033[0m"
puts
begin
IO.popen(command) do |io|
loop do
line = io.readline
puts ">> #{line}"
break if io.eof?
end
end
rescue => e
puts
print "\033[1;31m"
puts "There was a problem running the command: #{e.message}"
else
puts
print "\033[1;32m"
puts "Running command finished"
end
end
puts
program.each do |step|
print "\033[1;33m"
puts step['description']
continue?
run_and_print(step['command'])
continue?
puts `clear` if step['clear']
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment