commit 6e2a263124abbc2a43dd99878d2b76cdd6a3207e
parent 20dd3997907d82a14c455645bd5aaef08929bef0
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date: Sun, 17 Nov 2024 23:25:51 +0000
Prompt before reading extra secrets in generate command
Diffstat:
3 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/spec/action_spec.sh b/spec/action_spec.sh
@@ -1313,7 +1313,7 @@ Describe 'Action Functions'
#|> 0123456789
}
The status should be success
- The output should be blank
+ The output should equal 'Enter extra secrets then Ctrl+D when finished:'
The error should equal "$(result)"
End
@@ -1344,7 +1344,7 @@ Describe 'Action Functions'
#|> 0123456789
}
The status should be success
- The output should be blank
+ The output should equal 'Enter extra secrets then Ctrl+D when finished:'
The error should equal "$(result)"
End
@@ -1387,6 +1387,11 @@ Describe 'Action Functions'
ANSWER=y
}
When call do_generate existing 10 '[:alnum:]'
+ o_result(){
+ %text
+ #|Decrypting previous secret for existing
+ #|Enter extra secrets then Ctrl+D when finished:
+ }
result(){
%text:expand
#|$ scm_begin
@@ -1404,7 +1409,7 @@ Describe 'Action Functions'
#|> 0123456789
}
The status should be success
- The output should equal 'Decrypting previous secret for existing'
+ The output should equal "$(o_result)"
The error should equal "$(result)"
End
End
diff --git a/spec/pashage_extra_spec.sh b/spec/pashage_extra_spec.sh
@@ -720,10 +720,12 @@ Describe 'Integrated Command Functions'
When call cmd_generate --multiline new 15
The status should be success
The error should be blank
- The lines of output should equal 2
+ The lines of output should equal 3
The line 1 of output should \
+ equal 'Enter extra secrets then Ctrl+D when finished:'
+ The line 2 of output should \
equal '(B)The generated password for (U)new(!U) is:(N)'
- The line 2 of output should match pattern '???????????????'
+ The line 3 of output should match pattern '???????????????'
The lines of contents of file "${PREFIX}/new.age" should equal 3
The line 3 of contents of file "${PREFIX}/new.age" should \
equal 'age:extra comment line'
@@ -745,10 +747,12 @@ Describe 'Integrated Command Functions'
When call cmd_generate --multiline --force fluff/three 5
The status should be success
The error should be blank
- The lines of output should equal 2
+ The lines of output should equal 3
The line 1 of output should \
+ equal 'Enter extra secrets then Ctrl+D when finished:'
+ The line 2 of output should \
equal '(B)The generated password for (U)fluff/three(!U) is:(N)'
- The line 2 of output should match pattern '?????'
+ The line 3 of output should match pattern '?????'
The lines of contents of file "${PREFIX}/fluff/three.age" should equal 5
The line 4 of contents of file "${PREFIX}/fluff/three.age" should \
equal 'age:Extra: line'
@@ -772,12 +776,14 @@ Describe 'Integrated Command Functions'
When call cmd_generate --multiline --in-place fluff/three 5
The status should be success
The error should be blank
- The lines of output should equal 3
+ The lines of output should equal 4
The line 1 of output should \
equal 'Decrypting previous secret for fluff/three'
The line 2 of output should \
+ equal 'Enter extra secrets then Ctrl+D when finished:'
+ The line 3 of output should \
equal '(B)The generated password for (U)fluff/three(!U) is:(N)'
- The line 3 of output should match pattern '?????'
+ The line 4 of output should match pattern '?????'
The lines of contents of file "${PREFIX}/fluff/three.age" should equal 7
The line 4 of contents of file "${PREFIX}/fluff/three.age" should \
equal 'age:Username: 3Jane'
diff --git a/src/pashage.sh b/src/pashage.sh
@@ -673,6 +673,7 @@ do_generate_commit() {
fi
if [ "${MULTILINE}" = yes ]; then
+ echo 'Enter extra secrets then Ctrl+D when finished:'
while IFS='' read -r LINE; do
EXTRA="${EXTRA}${EXTRA:+${NL}}${LINE}"
done