rubtools 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22527797eacfb02733bc730908b3c0cfc5a192dd
4
- data.tar.gz: 5d8219a89981a3a0acb12b40924b6ef4d14ef4f4
3
+ metadata.gz: 21adde933d92eb32f75a27e329aadf1ebf5e10a2
4
+ data.tar.gz: 17ed0cdbb5fdcb4bfc64e4597970dd1b532b974c
5
5
  SHA512:
6
- metadata.gz: 6351028b8801489e355353db68c65f896fd06de170cc7277cdd1114eedd80ea37800f6ffafdcf4f747b11cff693fb499b540b9ea48ad74985344cfc9c44a7214
7
- data.tar.gz: 898fc255b24a6eafaab92df7f285445a78fac923d1ffb502c9fa6a66c4dd751a04f51b18d3b509fe4ace9d76aaab7d57891c2da56651cda48fd355fbda6a1063
6
+ metadata.gz: 70c7bef23f8dd9002fb5145493b5793de4fc2753f34ef1555154467f44372782bee14df42479883e04384fc3e9644099622fd584c1d5e275348e2c4516b8b09a
7
+ data.tar.gz: d8dfcc83a230e54dffa971a8dec8a8f7bf076b2e79f87da8a403b3aaba9cd5338e6f890138b1a873223b2bce24f12b8c65d6f4ab1e003c1e505557485e446c72
@@ -49,6 +49,10 @@ module Rubtools
49
49
  @options[:list] = l
50
50
  end
51
51
 
52
+ opts.on_tail("-C", "--cmplt", "Complete command") do |c|
53
+ @options[:cmplt] = c
54
+ end
55
+
52
56
  opts.on_tail("-h", "--help", "Show help") do
53
57
  Logger.verbose opts
54
58
  exit
@@ -96,20 +100,8 @@ module Rubtools
96
100
  end
97
101
  end
98
102
 
99
- if @options[:list]
100
- Logger.verbose "Available commands: \n\n"
101
- for constant in @tools.keys
102
- for method_hash in @tools[constant]
103
- params = method_hash.first.last.any? ? "(#{method_hash.first.last.join(", ")})" : nil
104
- Logger.success "#{constant}:#{method_hash.keys.first}#{params}"
105
- end
106
-
107
- if @tools[constant].any? && @tools.keys.last != constant
108
- Logger.verbose "\n"
109
- end
110
- end
111
- exit
112
- end
103
+ # Execute options before running recipes
104
+ execute_options
113
105
 
114
106
  begin
115
107
  raise ArgumentError, "missing arguments" unless @args.any?
@@ -144,5 +136,58 @@ module Rubtools
144
136
  end
145
137
  end
146
138
  end
139
+
140
+
141
+ private
142
+
143
+ ## Check and execute options
144
+ # - List available commands
145
+ # - Complete commands
146
+ #
147
+ def execute_options
148
+
149
+ for option in @options
150
+ ## List available commands
151
+ #
152
+ if option.first == :list && option.last
153
+ Logger.verbose "Available commands: \n\n"
154
+ for constant in @tools.keys
155
+ for method_hash in @tools[constant]
156
+ params = method_hash.first.last.any? ? "(#{method_hash.first.last.join(", ")})" : nil
157
+ Logger.success "#{constant}:#{method_hash.keys.first}#{params}"
158
+ end
159
+
160
+ if @tools[constant].any? && @tools.keys.last != constant
161
+ Logger.verbose "\n"
162
+ end
163
+ end
164
+ exit 0
165
+
166
+ ## Complete command
167
+ #
168
+ elsif option.first == :cmplt && option.last
169
+ args = @args.first.split(":")
170
+
171
+ if args.size == 1
172
+ for constant in @tools.keys
173
+ if constant.to_s.start_with? args.first
174
+ print constant.to_s + ":"
175
+ exit 0
176
+ end
177
+ end
178
+ elsif args.size == 2
179
+ for constant in @tools.keys
180
+ for method_hash in @tools[constant]
181
+ method_name = method_hash.keys.first
182
+ if method_name.to_s.start_with? args.last
183
+ print constant.to_s + ":" + method_name.to_s
184
+ exit 0
185
+ end
186
+ end
187
+ end
188
+ end
189
+ end
190
+ end
191
+ end
147
192
  end
148
193
  end
@@ -1,3 +1,3 @@
1
1
  module Rubtools
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -0,0 +1,10 @@
1
+ # rubtools_completion.bash
2
+
3
+ _rubtools_complete() {
4
+ COMPREPLY=()
5
+ local word="${COMP_WORDS[COMP_CWORD]}"
6
+ local completions="$(rt --cmplt "$word")"
7
+ COMPREPLY=( $(compgen -W "$completions" -- "$word") )
8
+ }
9
+
10
+ complete -f -F _rubtools_complete rt
@@ -0,0 +1,10 @@
1
+ # rubtools_completion.zsh
2
+
3
+ _rubtools_complete() {
4
+ local word completions
5
+ word="$1"
6
+ completions="$(rt --cmplt "${word}")"
7
+ reply=( "${(ps:\n:)completions}" )
8
+ }
9
+
10
+ compctl -f -K _rubtools_complete -S "" rt
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubtools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre FILSTROFF
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-01 00:00:00.000000000 Z
11
+ date: 2014-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: term-ansicolor
@@ -117,6 +117,8 @@ files:
117
117
  - lib/tools/git.rb
118
118
  - lib/tools/svn.rb
119
119
  - rubtools.gemspec
120
+ - rubtools_completion.bash
121
+ - rubtools_completion.zsh
120
122
  homepage: ''
121
123
  licenses:
122
124
  - MIT