knife-helper 0.0.4 → 0.0.5
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 +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +5 -0
- data/lib/chef/knife/helper_build.rb +35 -0
- data/lib/chef/knife/helper_exec.rb +3 -10
- data/lib/chef/knife/helper_list.rb +17 -21
- data/lib/knife/helper/config.rb +6 -1
- data/lib/knife/helper/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14c6110622c4edde3584a337c98f75abcca3c97c
|
4
|
+
data.tar.gz: 5077e912b6578899015e76b6080a175ca96eec3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 591747610f3b6fce891af75ebc8aea0ccf12cd9f90e0a78b25935cd4401484b2f26fd9fe2929f55b7018fe224eda8694aee1772eee8c4a986541cc9d6ac257f4
|
7
|
+
data.tar.gz: 2260af1ce1998386913b6fe673f98acdc6b689991489f41dfb6c777ba67d0894d78e17b61ee95cdb55e4edbba6ba0f82e064c42348e58dc83e3b862c26ad4028
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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
|
-
|
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
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
data/lib/knife/helper/config.rb
CHANGED
@@ -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
|
data/lib/knife/helper/version.rb
CHANGED
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
|
+
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
|