Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added -p option to CLI for auto pasting to clipboard on osx

git-svn-id: http://svn.addictedtonew.com/public/gems/lorem@170 fe7eae16-9a24-0410-a59d-9e59979e88be
  • Loading branch information...
commit 8fac31009c7fd958f41768db4f44745157213365 1 parent b5fe855
authored January 17, 2008
1  CHANGELOG.txt
... ...
@@ -1,2 +1,3 @@
  1
+0.1.2 - updated to allow auto paste to clipboard on osx using pbcopy
1 2
 0.1.0 - 4/17/2007
2 3
 	* initial release
34  bin/lorem
@@ -2,19 +2,27 @@
2 2
 require 'rubygems'
3 3
 require 'lorem'
4 4
 
5  
-number = ARGV.shift || 1
6  
-type = ARGV.shift || :paragraphs
  5
+PASTE_MODIFIER = '-p'
7 6
 
8  
-puts
9  
-puts Lorem::Base.new(type, number).output
10  
-puts
  7
+args   = ARGV.any? { |a| a == PASTE_MODIFIER } ? ARGV.reject { |a| a == PASTE_MODIFIER } : ARGV.dup
  8
+number = args.shift || 1
  9
+type   = args.shift || :paragraphs
  10
+output = Lorem::Base.new(type, number).output
11 11
 
12  
-if number == 1 && type == :paragraphs
13  
-  puts
14  
-  puts "Usage: lorem [number] [type] (ie: lorem 5 paragraphs)"
15  
-  puts " - Number defaults to 1 if no parameters given"
16  
-  puts " - Type defaults to paragraphs"
17  
-  puts " - Available Types:"
18  
-  Lorem::Base::TYPES.each { |t| puts "   - #{t}" }
19  
-  puts
  12
+if ARGV[-1] == PASTE_MODIFIER
  13
+  system("lorem #{number} #{type} | pbcopy")
  14
+  puts "Just pasted your request to the clipboard. (only works on osx)"
  15
+else
  16
+  puts output
  17
+  
  18
+  if number == 1 && type == :paragraphs
  19
+    puts
  20
+    puts "Usage: lorem [number] [type] (ie: lorem 5 paragraphs)"
  21
+    puts " - Number defaults to 1 if no parameters given"
  22
+    puts " - Type defaults to paragraphs"
  23
+    puts " - If you are on mac osx you can add -p as an argument and it will auto paste to your clipboard."
  24
+    puts " - Available Types:"
  25
+    Lorem::Base::TYPES.each { |t| puts "   - #{t}" }
  26
+    puts
  27
+  end
20 28
 end
2  lib/lorem/version.rb
@@ -2,7 +2,7 @@ module Lorem #:nodoc:
2 2
   module VERSION #:nodoc:
3 3
     MAJOR = 0
4 4
     MINOR = 1
5  
-    TINY  = 1
  5
+    TINY  = 2
6 6
 
7 7
     STRING = [MAJOR, MINOR, TINY].join('.')
8 8
   end

0 notes on commit 8fac310

Please sign in to comment.
Something went wrong with that request. Please try again.