thunder-1.8.7 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -7,6 +7,10 @@ Usage
7
7
 
8
8
  gem install thunder
9
9
 
10
+ or if you're running [ruby 1.8.7](http://www.ruby-lang.org/en/news/2011/10/06/plans-for-1-8-7):
11
+
12
+ gem install thunder-1.8.7
13
+
10
14
  see '[sample](http://github.com/stevenkaras/thunder/blob/master/sample)' for a quick overview of all features
11
15
 
12
16
  Philosophy
@@ -3,8 +3,8 @@
3
3
  require 'thunder'
4
4
  require 'erb'
5
5
 
6
- def thunder_commands(bolt)
7
- bolt[:commands].map(&:first).map(&:to_s)
6
+ def thunder_commands(spec)
7
+ spec[:commands].map(&:first).map(&:to_s)
8
8
  end
9
9
 
10
10
  def thunder_options(command)
@@ -19,53 +19,63 @@ def thunder_options(command)
19
19
  return result
20
20
  end
21
21
 
22
- module Thunder
23
- def start(args=ARGV.dup, options={})
24
- template = ERB.new <<-TEMPLATE, nil, "%"
25
- #!/bin/bash
22
+ def indent(text, amount, indent=" ")
23
+ result = ""
24
+ text.lines do |line|
25
+ result << indent * amount + line
26
+ end
27
+ return result
28
+ end
26
29
 
27
- % progname = File.basename(ARGV.first)
28
- __<%= progname %>_commands() {
29
- echo "<%= thunder_commands(thunder).join(" ") %>"
30
- }
31
- % thunder[:commands].each do |name, command|
30
+ def thunder_completion(depth, spec)
31
+ template = ERB.new <<-TEMPLATE, nil, "%>"
32
+ if ((COMP_CWORD == <%= depth+1 %>)); then
33
+ # display only commands
34
+ words="<%= thunder_commands(spec).join(" ") %>"
35
+ else
36
+ case ${COMP_WORDS[<%= depth+1 %>]} in
37
+ % spec[:commands].each do |name, command|
32
38
  % name = name.to_s
39
+ <%= name %>)
40
+ % if name == "help"
41
+ words="<%= thunder_commands(spec).join(" ") %>"
42
+ % end
33
43
  % if command[:options]
34
-
35
- __<%= progname %>_<%= name %>_options() {
36
- echo "<%= thunder_options(command).join(" ") %>"
37
- }
44
+ if [[ ${COMP_WORDS[COMP_CWORD]:0:1} == "-" ]]; then
45
+ words="<%= thunder_options(command).join(" ") %>"
46
+ fi
47
+ % end
48
+ % if command[:subcommand]
49
+ <%= indent(thunder_completion(depth+1, command[:subcommand].class.thunder), 8) %>
38
50
  % end
51
+ ;;
39
52
  % end
53
+ esac
54
+ fi
55
+ TEMPLATE
56
+ return template.result(binding)
57
+ end
40
58
 
41
- __<%= progname %>_complete() {
42
- local words=""
43
- if [[ ${COMP_WORDS[COMP_CWORD]:0:1} == "-" ]]; then
44
- if ((COMP_CWORD == 1)); then
45
- words=
46
- else
47
- local command="__<%= progname %>_${COMP_WORDS[1]}_options"
48
- words=$($command)
49
- fi
50
- elif ((COMP_CWORD == 1)); then
51
- # display only commands
52
- words=$(__<%= progname %>_commands)
53
- fi
59
+ module Thunder
60
+ def start(args=ARGV.dup, options={})
61
+ template = ERB.new <<-TEMPLATE, nil, "%>"
62
+ #!/bin/bash
63
+
64
+ % progname = File.basename(ARGV.first)
65
+ __<%= progname %>_completion() {
66
+ local words=""
67
+ <%= indent(thunder_completion(0, self.class.thunder), 4) %>
54
68
  COMPREPLY=($(compgen -W "$words" -- ${COMP_WORDS[COMP_CWORD]}))
55
69
  }
56
70
 
57
- complete -o default -o nospace -F __<%= progname %>_complete <%= progname %>
58
-
71
+ complete -o default -o nospace -F __<%= progname %>_completion <%= progname %>
59
72
  TEMPLATE
60
- context = (proc { |thiz, thunder|
61
- binding
62
- }).call(self, self.class.thunder)
63
- puts template.result(context)
73
+ puts template.result(binding)
64
74
  end
65
75
  end
66
76
 
67
77
  if ARGV.size != 1
68
- puts "Usage: thunder-completion THUNDER_SCRIPT"
78
+ puts "Usage: #{File.basename(__FILE__)} THUNDER_SCRIPT"
69
79
  puts
70
80
  puts "Prints out the suggested template for a bash completion script for the given thunder script"
71
81
  exit 1
data/bin/thunder-spec CHANGED
@@ -18,7 +18,7 @@ def renderThunderSpec(spec)
18
18
  end
19
19
 
20
20
  if ARGV.size != 1
21
- puts "Usage: thunder-spec THUNDER_SCRIPT"
21
+ puts "Usage: #{File.basename(__FILE__)} THUNDER_SCRIPT"
22
22
  puts
23
23
  puts "Dumps the thunder spec to the command line for debugging and analysis"
24
24
  exit 1
@@ -1,4 +1,4 @@
1
1
  module Thunder
2
2
  # Version string for gemspec
3
- VERSION = "0.5.2"
3
+ VERSION = "0.5.3"
4
4
  end
metadata CHANGED
@@ -1,24 +1,33 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: thunder-1.8.7
3
- version: !ruby/object:Gem::Version
4
- version: 0.5.2
3
+ version: !ruby/object:Gem::Version
4
+ hash: 13
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 3
10
+ version: 0.5.3
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Steven Karas
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2013-01-01 00:00:00.000000000 Z
17
+
18
+ date: 2013-01-02 00:00:00 Z
13
19
  dependencies: []
20
+
14
21
  description: Thunder does command line interfaces. Nothing more, nothing less.
15
22
  email: steven.karas@gmail.com
16
- executables:
23
+ executables:
17
24
  - thunder-spec
18
25
  - thunder-completion
19
26
  extensions: []
27
+
20
28
  extra_rdoc_files: []
21
- files:
29
+
30
+ files:
22
31
  - lib/thunder/help/default.rb
23
32
  - lib/thunder/version.rb
24
33
  - lib/thunder/options/optparse.rb
@@ -32,27 +41,36 @@ files:
32
41
  - bin/thunder-completion
33
42
  homepage: http://stevenkaras.github.com/thunder
34
43
  licenses: []
44
+
35
45
  post_install_message:
36
46
  rdoc_options: []
37
- require_paths:
47
+
48
+ require_paths:
38
49
  - lib
39
- required_ruby_version: !ruby/object:Gem::Requirement
50
+ required_ruby_version: !ruby/object:Gem::Requirement
40
51
  none: false
41
- requirements:
42
- - - ! '>='
43
- - !ruby/object:Gem::Version
44
- version: '0'
45
- required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
60
  none: false
47
- requirements:
48
- - - ! '>='
49
- - !ruby/object:Gem::Version
50
- version: '0'
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
67
+ version: "0"
51
68
  requirements: []
69
+
52
70
  rubyforge_project:
53
71
  rubygems_version: 1.8.24
54
72
  signing_key:
55
73
  specification_version: 3
56
74
  summary: Thunder makes command lines apps easy!
57
75
  test_files: []
58
- has_rdoc:
76
+