<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -19,6 +19,11 @@ To add a cheat sheet, use the --add switch.
 
 $ cheat readme --add
 
+To execute a sheet, use the --execute or -x switch.
+
+$ cheat rspec_rails_install_edge --execute
+$ cheat rspec_rails_install_edge --x
+
 Special Thanks To:
 - Evan Weaver
 - Kevin Marsh</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@ require 'rubygems'
 require 'rake'
 
 PACKAGE_NAME    = &quot;cheat&quot;
-PACKAGE_VERSION = &quot;1.2.1&quot;
+PACKAGE_VERSION = &quot;1.2.2&quot;
 
 SOURCE_FILES = FileList.new do |fl|
   [ &quot;bin&quot;, &quot;lib&quot;, &quot;test&quot; ].each do |dir|</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -20,10 +20,10 @@ module Cheat
     if %w[sheets all recent].include? @sheet
       options = headers.update(proxy_options)
       uri = uri.sub('/y/', @sheet == 'recent' ? '/yr/' : '/ya/')
-      return open(uri,options) { |body| show(body.read) }
+      return open(uri,options) { |body| process(body.read) }
     end
 
-    return show(File.read(cache_file)) if File.exists?(cache_file) rescue clear_cache if cache_file 
+    return process(File.read(cache_file)) if File.exists?(cache_file) rescue clear_cache if cache_file 
 
     fetch_sheet(uri + @sheet) if @sheet
   end
@@ -32,6 +32,7 @@ module Cheat
     options = headers.update(proxy_options)
     open(uri, options) do |body|
       sheet = body.read
+      FileUtils.mkdir_p(cache_dir) unless File.exists?(cache_dir)
       File.open(cache_file, 'w') { |f| f.write(sheet) } if try_to_cache &amp;&amp; cache_file &amp;&amp; !@edit 
       @edit ? edit(sheet) : show(sheet)
     end 
@@ -56,7 +57,8 @@ module Cheat
 
     add(args.shift) and return if args.delete('--add')
     clear_cache if @edit = args.delete('--edit')
-
+    
+    @execute = true if args.delete(&quot;--execute&quot;) || args.delete(&quot;-x&quot;)
     @sheet = args.shift
 
     true
@@ -102,6 +104,31 @@ module Cheat
     &quot;#{HOST}:#{PORT}#{SUFFIX}&quot;
   end
 
+  def execute(sheet_yaml)
+    sheet_body = YAML.load(sheet_yaml).to_a.flatten.last
+    puts &quot;\n  &quot; + sheet_body.gsub(&quot;\r&quot;,'').gsub(&quot;\n&quot;, &quot;\n  &quot;).wrap
+    puts &quot;\nWould you like to execute the above sheet? (Y/N)&quot;
+    answer = STDIN.gets
+    case answer.chomp
+    when &quot;Y&quot; then system YAML.load(sheet_yaml).to_a.flatten.last
+    when &quot;N&quot; then puts &quot;Not executing sheet.&quot;
+    else
+      puts &quot;Must be Y or N!&quot;
+    end
+  rescue Errno::EPIPE
+    # do nothing
+  rescue
+    puts &quot;That didn't work.  Maybe try `$ cheat cheat' for help?&quot; # Fix Emacs ruby-mode highlighting bug: `&quot;
+  end
+
+  def process(sheet_yaml)
+    if @execute
+      execute(sheet_yaml)
+    else
+      show(sheet_yaml)
+    end
+  end
+
   def show(sheet_yaml)
     sheet = YAML.load(sheet_yaml).to_a.first
     sheet[-1] = sheet.last.join(&quot;\n&quot;) if sheet[-1].is_a?(Array)</diff>
      <filename>lib/cheat.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>406090dac0834041f3e69afa70e326ff0b1bfc1d</id>
    </parent>
  </parents>
  <author>
    <name>Zach Dennis</name>
    <email>zach.dennis@gmail.com</email>
  </author>
  <url>http://github.com/shayarnett/cheat/commit/5eafa94db4544c00b68c2c7bbac99ba83ed272c8</url>
  <id>5eafa94db4544c00b68c2c7bbac99ba83ed272c8</id>
  <committed-date>2008-12-03T17:37:12-08:00</committed-date>
  <authored-date>2008-08-01T11:44:50-07:00</authored-date>
  <message>Added the --execute and -x options to execute a sheet body. It will show the sheet body to the user and then ask them if they want to execute it or not to avoid security issues.</message>
  <tree>21fdfc4f59dcf3897ffcaa6dc5ffa09bc02bee59</tree>
  <committer>
    <name>Chris Wanstrath</name>
    <email>chris@ozmm.org</email>
  </committer>
</commit>
