knife-helper 0.0.3 → 0.0.4

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: 3d8d47d7494a1ece95286151574f566669c80616
4
- data.tar.gz: aae10db6ef15f2f3a842655b52f01a031953e98d
3
+ metadata.gz: a78adf4c9784639e68738be65b5fbee92afda29b
4
+ data.tar.gz: fc00c910f235ff14e367ca59f06d357a4f8cec3b
5
5
  SHA512:
6
- metadata.gz: 0e2a7d473d14b0ffe723cf08f639e7c4a77b61701b0eed5760d5a60cf472a9d11149d61fea52446581fec6ee69f28057a5790d7fb16881ba1ec25834176aae90
7
- data.tar.gz: 0c032eada7bef7e7da1e4e60ee783dbf725636cd7c49cb5b70dc8c07b099a69e0c510c4d22c3e959bd46d3b3f622e55f3ca552cec8a3e814f2ed796ab1e479cb
6
+ metadata.gz: 021e049241049d555172c8d497f11d8ce8e2f26d20b96d10cf8c30d89a467eace0957ef04d954dd68866949254afef30f8430f531df968e7e0f0586924befbf7
7
+ data.tar.gz: f5035e53a8c15a3bd03af4b5f8be69321cfa3b5643a26885b8f9b6a4439b30c1612ef5cd3fcf1d506ec611c32f99c1887fc7e19fa80c8c7afa1704dba0d7b3d2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.0.4
2
+
3
+ * Add `list` subcommand [#4] ([@sawanoboly])
4
+
1
5
  ## 0.0.3
2
6
 
3
7
  * Support some external configuration files [#2]
@@ -13,3 +17,5 @@
13
17
 
14
18
  <!--- The following link definition list is generated by PimpMyChangelog --->
15
19
  [#2]: https://github.com/marcy-terui/knife-helper/issues/2
20
+ [#4]: https://github.com/marcy-terui/knife-helper/issues/4
21
+ [@sawanoboly]: https://github.com/sawanoboly
@@ -0,0 +1,42 @@
1
+ require 'chef'
2
+ require 'knife/helper/commands'
3
+ require 'knife/helper/config'
4
+
5
+ class Chef
6
+ class Knife
7
+ class HelperList < Chef::Knife
8
+
9
+ banner "knife helper list REGEX (option)"
10
+
11
+ option :file,
12
+ :short => "-f FILE",
13
+ :long => "--file FILE",
14
+ :description => "Path to config file(yaml)",
15
+ :default => ""
16
+
17
+ def run
18
+ file = config[:file] == "" ? default_config_file : config[:file]
19
+ commands = ::Knife::Helper::Commands.new(
20
+ ::Knife::Helper::Config.new(file).data
21
+ )
22
+ unless @name_args.empty?
23
+ cm = commands.commands.select{|c| Regexp.new(@name_args.first).match(c['name']) }
24
+ else
25
+ cm = commands.commands
26
+ end
27
+ hash = {}
28
+ cm.map! do |c|
29
+ hash[c['name']] = c['command']
30
+ end
31
+ output(ui.presenter.format_for_display(hash))
32
+ end
33
+
34
+ private
35
+
36
+ def default_config_file
37
+ ::File.join(Dir.pwd, ".knife.helper.yml")
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -3,6 +3,8 @@ module Knife
3
3
  module Helper
4
4
  class Commands
5
5
 
6
+ attr_reader :commands
7
+
6
8
  def initialize(config)
7
9
  @base = config['settings']['command_base']
8
10
  @commands = config['commands']
@@ -1,5 +1,5 @@
1
1
  module Knife
2
2
  module Helper
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masashi Terui
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-10 00:00:00.000000000 Z
11
+ date: 2015-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -112,6 +112,7 @@ files:
112
112
  - knife-helper.gemspec
113
113
  - lib/chef/knife/helper_exec.rb
114
114
  - lib/chef/knife/helper_init.rb
115
+ - lib/chef/knife/helper_list.rb
115
116
  - lib/knife/helper.rb
116
117
  - lib/knife/helper/commands.rb
117
118
  - lib/knife/helper/config.rb