prompt_manager 0.5.4 → 0.5.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/CHANGELOG.md +6 -0
- data/lib/prompt_manager/prompt.rb +16 -0
- data/lib/prompt_manager/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e471d6dde897f90fcedcabaacdd7a2fb78528b43f73812382b88da07ff655ef
|
4
|
+
data.tar.gz: d077a281f07a40eae6ab59caa06278d175abb42855088ccf98659fc97e95a003
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdb1c938936daa947678e48c27f55b4e7e66d05d2fbe791db4e45a3da94aebda1cdb2a7bb8f303e36b1d5c97a704d6a0588d2c852c6fd1e6c5f7c20ca1dabe6b
|
7
|
+
data.tar.gz: 83395ce83ea16edab586f36fec2e04370c573324053bb2cc0f59e81f0c3188a51408ac08b23ecfd095d7412a256ef264f713c1965ca6ac1cb014902e8814f5fb
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
3
|
## Released
|
4
|
+
### [0.5.6] = 2025-06-04
|
5
|
+
- fixed a problem where shell integration was not working correctly for $(shell command)
|
6
|
+
|
7
|
+
### [0.5.5] = 2025-05-21
|
8
|
+
- fixed bug in parameter substitution when value is an Array now uses last entry
|
9
|
+
|
4
10
|
### [0.5.4] = 2025-05-18
|
5
11
|
- fixed typo in the Prompt class envvar should have been envar which prevented shell integration from taking place.
|
6
12
|
|
@@ -146,6 +146,7 @@ class PromptManager::Prompt
|
|
146
146
|
def substitute_values(input_text, values_hash)
|
147
147
|
if values_hash.is_a?(Hash) && !values_hash.empty?
|
148
148
|
values_hash.each do |key, value|
|
149
|
+
value = value.last if value.is_a?(Array)
|
149
150
|
input_text = input_text.gsub(key, value)
|
150
151
|
end
|
151
152
|
end
|
@@ -158,6 +159,21 @@ class PromptManager::Prompt
|
|
158
159
|
def substitute_env_vars(input_text)
|
159
160
|
return input_text unless envar?
|
160
161
|
|
162
|
+
# First, handle shell command substitution $(command)
|
163
|
+
input_text = input_text.gsub(/\$\(([^\)]+)\)/) do |match|
|
164
|
+
cmd = $1.strip
|
165
|
+
begin
|
166
|
+
# Execute the shell command and capture its output
|
167
|
+
result = `#{cmd}`.chomp
|
168
|
+
result.empty? ? match : result
|
169
|
+
rescue => e
|
170
|
+
# If command execution fails, log the error and keep the original text
|
171
|
+
warn "Shell command execution failed: #{e.message}"
|
172
|
+
match
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# Then handle environment variables as before
|
161
177
|
input_text.gsub(/\$(\w+)|\$\{(\w+)\}/) do |match|
|
162
178
|
env_var = $1 || $2
|
163
179
|
ENV[env_var] || match
|