snipper 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,6 +41,33 @@ class MyCLI<Thor
41
41
  puts Snipper::Util.append(snippet, [file1, file2, file3, file4, file5].compact, options["syntax"], options["description"])
42
42
  end
43
43
 
44
+ desc "capture", "Captures the output of a command as a snippet"
45
+ long_desc <<-D
46
+ Captures the output of a unix command to a snippet
47
+
48
+ $ snipper append -l text -d 'some description' 'ls -l'
49
+
50
+ Alternatively you can if you do not supply a command you will receive a prompt
51
+
52
+ $ snipper append -l text -d 'some description'
53
+ command > ls -l
54
+ D
55
+ option :syntax, :desc => "Language to use for the new snippet", :default => "text", :type => :string, :aliases => ["-l", "--lang", "-s"]
56
+ option :description, :desc => "Textual description for this snippet", :default => nil, :type => :string, :aliases => ["-d"]
57
+ def capture(*command)
58
+ if command.empty?
59
+ require "readline"
60
+ command = Readline.readline('command> ', true)
61
+ else
62
+ command = command.join(" ")
63
+ end
64
+
65
+ abort "Please enter a command to capture" if command.size == 0
66
+
67
+ description = options.fetch("description", "captured output of: %s" % command)
68
+ puts Snipper::Util.capture(command, options["syntax"], options.fetch("description", command))
69
+ end
70
+
44
71
  desc "delete [SNIPPET]", "deletes an existing snippet"
45
72
  def delete(snippet)
46
73
  Snipper::Util.delete(snippet)
@@ -40,6 +40,11 @@ class Snipper
40
40
  snip.url_for_snippet
41
41
  end
42
42
 
43
+ def self.capture(command, syntax, description)
44
+ snipper = Snipper.new
45
+ Snippet.new(%x{#{command}}, {:syntax => syntax, :description => description}).url_for_snippet
46
+ end
47
+
43
48
  def self.append(snippet_id, snippet, syntax, description)
44
49
  snipper = Snipper.new
45
50
 
@@ -1,3 +1,3 @@
1
1
  class Snipper
2
- VERSION="0.0.4"
2
+ VERSION="0.0.5"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snipper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - R.I.Pienaar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-06-20 00:00:00 +01:00
18
+ date: 2012-08-31 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency