knife-helper 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a78adf4c9784639e68738be65b5fbee92afda29b
4
- data.tar.gz: fc00c910f235ff14e367ca59f06d357a4f8cec3b
3
+ metadata.gz: 14c6110622c4edde3584a337c98f75abcca3c97c
4
+ data.tar.gz: 5077e912b6578899015e76b6080a175ca96eec3b
5
5
  SHA512:
6
- metadata.gz: 021e049241049d555172c8d497f11d8ce8e2f26d20b96d10cf8c30d89a467eace0957ef04d954dd68866949254afef30f8430f531df968e7e0f0586924befbf7
7
- data.tar.gz: f5035e53a8c15a3bd03af4b5f8be69321cfa3b5643a26885b8f9b6a4439b30c1612ef5cd3fcf1d506ec611c32f99c1887fc7e19fa80c8c7afa1704dba0d7b3d2
6
+ metadata.gz: 591747610f3b6fce891af75ebc8aea0ccf12cd9f90e0a78b25935cd4401484b2f26fd9fe2929f55b7018fe224eda8694aee1772eee8c4a986541cc9d6ac257f4
7
+ data.tar.gz: 2260af1ce1998386913b6fe673f98acdc6b689991489f41dfb6c777ba67d0894d78e17b61ee95cdb55e4edbba6ba0f82e064c42348e58dc83e3b862c26ad4028
data/.travis.yml CHANGED
@@ -12,4 +12,6 @@ matrix:
12
12
  script:
13
13
  - bundle exec rake
14
14
  - bundle exec knife helper init -B -L
15
+ - bundle exec knife helper list
16
+ - bundle exec knife helper build default
15
17
  - bundle exec knife helper exec default
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.0.5
2
+
3
+ * Add `build` subcommand (Previously was `list`)
4
+ * Change `list` subcommand to only listing
5
+
1
6
  ## 0.0.4
2
7
 
3
8
  * Add `list` subcommand [#4] ([@sawanoboly])
@@ -0,0 +1,35 @@
1
+ require 'chef'
2
+ require 'knife/helper/commands'
3
+ require 'knife/helper/config'
4
+
5
+ class Chef
6
+ class Knife
7
+ class HelperBuild < Chef::Knife
8
+
9
+ banner "knife helper build REGEX (option)"
10
+
11
+ option :file,
12
+ :short => "-f FILE",
13
+ :long => "--file FILE",
14
+ :description => "Path to config file(yaml)",
15
+ :default => nil
16
+
17
+ def run
18
+ commands = ::Knife::Helper::Commands.new(
19
+ ::Knife::Helper::Config.new(config[:file]).data
20
+ )
21
+ unless @name_args.empty?
22
+ cm = commands.commands.select{|c| Regexp.new(@name_args.first).match(c['name']) }
23
+ else
24
+ cm = commands.commands
25
+ end
26
+ hash = {}
27
+ cm.map! do |c|
28
+ hash[c['name']] = c['command']
29
+ end
30
+ output(ui.presenter.format_for_display(hash))
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -19,28 +19,21 @@ class Chef
19
19
  :short => "-f FILE",
20
20
  :long => "--file FILE",
21
21
  :description => "Path to config file(yaml)",
22
- :default => ""
22
+ :default => nil
23
23
 
24
24
  def run
25
- file = config[:file] == "" ? default_config_file : config[:file]
26
25
  commands = ::Knife::Helper::Commands.new(
27
- ::Knife::Helper::Config.new(file).data
26
+ ::Knife::Helper::Config.new(config[:file]).data
28
27
  )
29
28
  @name_args.each do |cmd|
30
29
  if config[:print_command]
31
- puts commands.build(cmd)
30
+ output commands.build(cmd)
32
31
  else
33
32
  commands.exec(cmd)
34
33
  end
35
34
  end
36
35
  end
37
36
 
38
- private
39
-
40
- def default_config_file
41
- ::File.join(Dir.pwd, ".knife.helper.yml")
42
- end
43
-
44
37
  end
45
38
  end
46
39
  end
@@ -6,35 +6,31 @@ class Chef
6
6
  class Knife
7
7
  class HelperList < Chef::Knife
8
8
 
9
- banner "knife helper list REGEX (option)"
9
+ banner "knife helper list"
10
10
 
11
11
  option :file,
12
12
  :short => "-f FILE",
13
13
  :long => "--file FILE",
14
14
  :description => "Path to config file(yaml)",
15
- :default => ""
15
+ :default => nil
16
+
17
+ option :all,
18
+ :short => "-a",
19
+ :long => "--all",
20
+ :description => "Print all commands and options",
21
+ :boolean => true,
22
+ :default => false
16
23
 
17
24
  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']
25
+ ::Knife::Helper::Commands.new(
26
+ ::Knife::Helper::Config.new(config[:file]).data
27
+ ).commands.each do |c|
28
+ if config[:all]
29
+ output(ui.presenter.format_for_display(c))
30
+ else
31
+ output c['name']
32
+ end
30
33
  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
34
  end
39
35
 
40
36
  end
@@ -8,7 +8,8 @@ module Knife
8
8
 
9
9
  attr_reader :data
10
10
 
11
- def initialize(file)
11
+ def initialize(file=nil)
12
+ file ||= default_file
12
13
  @data = load_config(file)
13
14
  end
14
15
 
@@ -27,6 +28,10 @@ module Knife
27
28
  conf
28
29
  end
29
30
 
31
+ def default_file
32
+ ::File.join(Dir.pwd, ".knife.helper.yml")
33
+ end
34
+
30
35
  def read_file(file)
31
36
  ::File.exist?(file.to_s) ? IO.read(file) : ""
32
37
  end
@@ -1,5 +1,5 @@
1
1
  module Knife
2
2
  module Helper
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masashi Terui
@@ -110,6 +110,7 @@ files:
110
110
  - README.md
111
111
  - Rakefile
112
112
  - knife-helper.gemspec
113
+ - lib/chef/knife/helper_build.rb
113
114
  - lib/chef/knife/helper_exec.rb
114
115
  - lib/chef/knife/helper_init.rb
115
116
  - lib/chef/knife/helper_list.rb