pashage

Yet Another Opinionated Re-engineering of the Unix Password Store
git clone https://git.instinctive.eu/pashage.git
Log | Files | Refs | README | LICENSE

commit 6a22a4c4186c7129855d9116ef8654a8b448a640
parent 4a43e32c0fc1d0261f72e9621f50d7ac952c0962
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date:   Sat, 16 Nov 2024 12:35:43 +0000

Default state is set by command functions rather than run.sh
Diffstat:
Mspec/pashage_extra_spec.sh | 22----------------------
Mspec/usage_spec.sh | 10----------
Msrc/pashage.sh | 22++++++++++++++++++----
Msrc/run.sh | 8--------
4 files changed, 18 insertions(+), 44 deletions(-)

diff --git a/spec/pashage_extra_spec.sh b/spec/pashage_extra_spec.sh @@ -189,9 +189,6 @@ Describe 'Integrated Command Functions' # Describe 'cmd_copy' is not needed (covered by 'cmd_copy_move') Describe 'cmd_copy_move' - DECISION=default - OVERWRITE=no - It 'processes several files and directories into a directory' When call cmd_move extra stale subdir The status should be success @@ -421,8 +418,6 @@ Describe 'Integrated Command Functions' End Describe 'cmd_delete' - DECISION=default - It 'deletes multiple files at once, prompting before each one' Data #|y @@ -612,11 +607,6 @@ Describe 'Integrated Command Functions' End Describe 'cmd_generate' - DECISION=default - MULTILINE=no - OVERWRITE=no - SHOW=text - It 'uses the character set given explicitly instead of environment' CHARACTER_SET='[0-9]' CHARACTER_SET_NO_SYMBOLS='[0-9]' @@ -946,10 +936,6 @@ Describe 'Integrated Command Functions' End Describe 'cmd_insert' - ECHO=no - MULTILINE=no - OVERWRITE=no - It 'inserts an entry encrypted using an explicit recipient file' PASHAGE_RECIPIENTS_FILE="${PREFIX}/fluff/.age-recipients" PASSAGE_RECIPIENTS_FILE="${PREFIX}/shared/.age-recipients" @@ -1163,8 +1149,6 @@ Describe 'Integrated Command Functions' End Describe 'cmd_list_or_show' - SHOW=text - It 'decrypts a GPG secret in the store using GPG' GPG=mock-gpg gpg() { false; } @@ -1525,8 +1509,6 @@ Describe 'Integrated Command Functions' End Example 'delete' - DECISION=force - OVERWRITE=no When run cmd_delete stale The status should equal 1 The error should equal 'There are already pending changes.' @@ -1545,9 +1527,6 @@ Describe 'Integrated Command Functions' # 'find' does not change the repository Example 'generate' - DECISION=default - MULTILINE=no - OVERWRITE=no When run cmd_generate new-pass The status should equal 1 The error should equal 'There are already pending changes.' @@ -1585,7 +1564,6 @@ Describe 'Integrated Command Functions' End Example 'insert' - MULTILINE=no When run cmd_insert -e fluff/four The status should equal 1 The error should equal 'There are already pending changes.' diff --git a/spec/usage_spec.sh b/spec/usage_spec.sh @@ -32,12 +32,6 @@ Describe 'Command-Line Parsing' CHARACTER_SET='[:punct:][:alnum:]' CHARACTER_SET_NO_SYMBOLS='[:alnum:]' - DECISION=default - ECHO=no - MULTILINE=no - OVERWRITE=no - SELECTED_LINE=1 - SHOW=text # mocks platform_tmpdir() { @@ -400,7 +394,6 @@ Describe 'Command-Line Parsing' Describe 'cmd_delete' COMMAND=delete - RECURSIVE=no It 'removes a file forcefully with a long option' result() { @@ -1645,8 +1638,6 @@ Describe 'Command-Line Parsing' Describe 'cmd_list_or_show' COMMAND= - SELECTED_LINE=1 - SHOW=text It 'lists the whole store' result() { @@ -2128,7 +2119,6 @@ Describe 'Command-Line Parsing' Describe 'cmd_reencrypt' COMMAND=reencrypt - DECISION=default It 're-encrypts multiple files and directories' result() { diff --git a/src/pashage.sh b/src/pashage.sh @@ -614,8 +614,8 @@ do_encrypt() { # $2: new password length # $3: new password charset # DECISION: when interactive, show-ask-commit instead of commit-show -# MULTILINE: whether to re-use existing secret data # OVERWRITE: whether to overwrite without confirmation +# MULTILINE: whether to re-use existing secret data do_generate() { NEW_PASS="$(random_chars "$2" "$3")" NEW_PASS_LEN="$(strlen "${NEW_PASS}")" @@ -780,8 +780,8 @@ do_init() { # Insert a new secret from standard input # $1: entry name # ECHO: whether interactive echo is kept -# OVERWRITE: whether to overwrite without confirmation # MULTILINE: whether whole standard input is used +# OVERWRITE: whether to overwrite without confirmation do_insert() { if [ -e "${PREFIX}/$1.age" ] && [ "${OVERWRITE}" = no ]; then yesno "An entry already exists for $1. Overwrite it?" @@ -1065,7 +1065,10 @@ cmd_copy() { } cmd_copy_move() { + DECISION=default + OVERWRITE=no PARSE_ERROR=no + while [ $# -ge 1 ]; do case "$1" in -f|--force) @@ -1136,8 +1139,10 @@ cmd_copy_move() { } cmd_delete() { + DECISION=default PARSE_ERROR=no RECURSIVE=no + while [ $# -ge 1 ]; do case "$1" in -f|--force) @@ -1203,9 +1208,13 @@ cmd_find() { } cmd_generate() { - PARSE_ERROR=no CHARSET="${CHARACTER_SET}" - VERB="Add" + DECISION=default + MULTILINE=no + OVERWRITE=no + PARSE_ERROR=no + SELECTED_LINE=1 + SHOW=text while [ $# -ge 1 ]; do case "$1" in @@ -1410,7 +1419,11 @@ cmd_init() { } cmd_insert() { + ECHO=no + MULTILINE=no + OVERWRITE=no PARSE_ERROR=no + while [ $# -ge 1 ]; do case "$1" in -e|--echo) @@ -1460,6 +1473,7 @@ cmd_insert() { cmd_list_or_show() { PARSE_ERROR=no + SELECTED_LINE=1 USE_CLIP=no USE_QRCODE=no diff --git a/src/run.sh b/src/run.sh @@ -75,14 +75,6 @@ unset GIT_OBJECT_DIRECTORY unset GIT_COMMON_DIR export GIT_CEILING_DIRECTORIES="${PREFIX}/.." -### Default state -DECISION=default #default|force|keep|interactive -ECHO=no -MULTILINE=no -OVERWRITE=no -SELECTED_LINE=1 -SHOW=text - ########### # IMPORTS # ###########