cl-magic 1.2.3 → 1.2.6
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/Gemfile.lock +1 -1
- data/lib/cl/magic/cl-dk-parts +10 -7
- data/lib/cl/magic/common/parse_and_pick.rb +9 -1
- data/lib/cl/magic/dk/yaml_arg_munger.rb +9 -2
- data/lib/cl/magic/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee9d7e3bde502a316983f3a3e60bce059f2db898be8bd14c16c3af083366814c
|
4
|
+
data.tar.gz: 4c122eff717df5d5b41c9e0e1aa900d263bb285aa3e21df5d20782da18ad2e1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d99fc06858b996a81885198a5eb599dc02ca571aa438782c4f73ab62bfad523a332f2a1202f3c8d44ee12c7be9f4d787719494893569c72dff6fbce84f51748
|
7
|
+
data.tar.gz: fd550cf63318a0615c32d410d5a588811d19de59d1c7f0df7f18c8dcb099ff7cbd21904ed509d6ed8987857205c7491676086da31c0a7d62ec4eb406614d4ef7
|
data/Gemfile.lock
CHANGED
data/lib/cl/magic/cl-dk-parts
CHANGED
@@ -65,7 +65,11 @@ def do_set(options)
|
|
65
65
|
|
66
66
|
# save parts
|
67
67
|
filepath = get_save_parts_filepath()
|
68
|
+
prev_saved_parts = YAML.load_file(filepath)
|
69
|
+
|
70
|
+
# passed in parts
|
68
71
|
parts = ARGV[1..]
|
72
|
+
|
69
73
|
case options[:action]
|
70
74
|
when :set
|
71
75
|
unless parts.any?
|
@@ -73,7 +77,8 @@ def do_set(options)
|
|
73
77
|
@logger.info "enter to complete"
|
74
78
|
@logger.puts ""
|
75
79
|
options = dk_parts_hash.keys.collect {|k| [k.ljust(25, ' '), dk_parts_hash[k]['help']]}
|
76
|
-
|
80
|
+
default = prev_saved_parts.collect{|p| p.ljust(25, ' ')}
|
81
|
+
selected_parts = pick_multiple_result(options, "Which parts?", nil, false, default)
|
77
82
|
parts = selected_parts.collect {|o| o.first.strip}
|
78
83
|
end
|
79
84
|
File.open(filepath, 'w') { |file| file.write(parts.to_yaml) }
|
@@ -89,14 +94,12 @@ def do_set(options)
|
|
89
94
|
do_clear(options)
|
90
95
|
end
|
91
96
|
when :add
|
92
|
-
|
93
|
-
|
94
|
-
File.open(filepath, 'w') { |file| file.write(data.uniq.to_yaml) }
|
97
|
+
parts.each {|p| prev_saved_parts << p}
|
98
|
+
File.open(filepath, 'w') { |file| file.write(prev_saved_parts.uniq.to_yaml) }
|
95
99
|
@logger.success "parts added"
|
96
100
|
when :remove
|
97
|
-
|
98
|
-
|
99
|
-
File.open(filepath, 'w') { |file| file.write(data.to_yaml) }
|
101
|
+
prev_saved_parts.reject! { |p| parts.include?(p) }
|
102
|
+
File.open(filepath, 'w') { |file| file.write(prev_saved_parts.to_yaml) }
|
100
103
|
@logger.success "parts removed"
|
101
104
|
end
|
102
105
|
else
|
@@ -63,7 +63,7 @@ def pick_single_result(results, prompt_message, exact=nil, default=nil, selectio
|
|
63
63
|
end
|
64
64
|
|
65
65
|
|
66
|
-
def pick_multiple_result(results, prompt_message, exacts=nil, echo=true)
|
66
|
+
def pick_multiple_result(results, prompt_message, exacts=nil, echo=true, default=[])
|
67
67
|
|
68
68
|
# exact match?
|
69
69
|
return results.select {|r| exacts.split(',').include? r.first} if exacts
|
@@ -72,9 +72,17 @@ def pick_multiple_result(results, prompt_message, exacts=nil, echo=true)
|
|
72
72
|
return results if results.count < 2
|
73
73
|
|
74
74
|
selections = TTY::Prompt.new(interrupt: :exit).multi_select(prompt_message, filter: true, per_page: 20, echo: echo) do |menu|
|
75
|
+
# add choices
|
75
76
|
results.each do |result|
|
76
77
|
menu.choice result.join(' | '), result.first
|
77
78
|
end
|
79
|
+
|
80
|
+
# defaults
|
81
|
+
keys = results.collect {|r|r.first}
|
82
|
+
default_indexes = default.map {|d| keys.index(d) + 1}
|
83
|
+
if default.any?
|
84
|
+
menu.default *default_indexes
|
85
|
+
end
|
78
86
|
end
|
79
87
|
|
80
88
|
return results.select {|r| selections.include? r.first}
|
@@ -53,11 +53,18 @@ class YamlArgMunger
|
|
53
53
|
return hash ? hash : {}
|
54
54
|
end
|
55
55
|
|
56
|
-
def merge_world_files(compose_hash, show_help=false)
|
56
|
+
def merge_world_files(compose_hash, show_help=false)
|
57
57
|
if @dk_proj_path
|
58
58
|
print_dk_help_line("dk-project-path", "#{@dk_proj_path}") if show_help and $stdout.isatty
|
59
59
|
|
60
|
-
|
60
|
+
# sorted yaml files
|
61
|
+
sorted_files = Dir.glob("#{@dk_proj_path}/*.{yml,yaml}", File::FNM_DOTMATCH).sort
|
62
|
+
|
63
|
+
# apply .local.yml last
|
64
|
+
sorted_files.push(sorted_files.shift) if sorted_files.first == "#{@dk_proj_path}/.local.yml"
|
65
|
+
|
66
|
+
# merge each file
|
67
|
+
sorted_files.each do |filepath|
|
61
68
|
print_dk_help_line("dk-world", "#{filepath}") if show_help and $stdout.isatty
|
62
69
|
|
63
70
|
# read file and replace
|
data/lib/cl/magic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cl-magic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Don Najd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|