commit a284e56f55fbe916754ed37999e23ecaa54dfba7
parent 2a562f1e1d852068ecd6501929e1b8f6d62f5c0f
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date: Sun, 2 Nov 2025 18:08:27 +0000
Find command has a raw list output option
Diffstat:
5 files changed, 63 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
@@ -78,6 +78,9 @@ passwords.
- The commands `copy` and `move` have new flags to control re-encryption
(always, never, ask for each file).
+- The `find` and `list` commands have a new flag to output a
+machine-readable list of entries (e.g. for completion or wrappers).
+
- The `generate` command has a new command-line argument to specify
explicitly the character set.
@@ -91,9 +94,6 @@ the generated secret (e.g. for username, login page, or others comments).
- The `init` command has new flags to control re-encryption (never or
ask for each file).
-- The `list` command has a new flag to output a machine-readable list of
-entries (e.g. for completion or wrappers).
-
- The new `gitconfig` command configures an existing store repository to
decrypt before `diff`.
@@ -264,12 +264,16 @@ Environment:
Syntax:
```
-pashage find [GREP_OPTIONS] regex
+pashage find [--raw,-r] [GREP_OPTIONS] regex
```
This subcommand lists as a tree the secrets whose name match the given
regular expression, using the corresponding `grep(1)` options.
+Flags:
+- `-r` or `--raw`: display the results as a raw list of secrets,
+ rather than a tree
+
Environment:
- `CLICOLOR`: when set to a non-empty value, use ANSI escape sequences to
color the output
diff --git a/pashage.1 b/pashage.1
@@ -1,4 +1,4 @@
-.Dd October 31, 2025
+.Dd November 2, 2025
.Dt PASHAGE 1
.Os
.Sh NAME
@@ -101,6 +101,7 @@ This subcommand starts an interactive editor to update the secrets.
.Ss find
.Nm
.Cm find
+.Op Fl r,--raw
.Op Ar GREP_OPTIONS
.Ar regex
.Pp
@@ -108,6 +109,12 @@ This subcommand lists as a tree the secrets whose name match the given
regular expression, using the corresponding
.Xr grep 1
options.
+.Pp
+The options are as follows:
+.Bl -tag -compact -width \-i,--interactive
+.It Fl r,--raw
+display the results as a raw list of secrets, rather than a tree
+.El
.Ss generate
.Nm
.Cm generate
diff --git a/spec/pashage_extra_spec.sh b/spec/pashage_extra_spec.sh
@@ -604,6 +604,18 @@ Describe 'Integrated Command Functions'
The error should be blank
The result of function check_git_log should be successful
End
+
+ It 'can output a raw list of secrets'
+ expected_output() { %text
+ #|extra/subdir/file
+ #|subdir/file
+ }
+ When call cmd_find -r -E -i 'F|I'
+ The status should be success
+ The output should equal "$(expected_output)"
+ The error should be blank
+ The result of function check_git_log should be successful
+ End
End
Describe 'cmd_generate'
diff --git a/spec/usage_spec.sh b/spec/usage_spec.sh
@@ -112,6 +112,9 @@ Describe 'Command-Line Parsing'
#|MULTILINE=${MULTILINE}
#|OVERWRITE=${OVERWRITE}
}
+ do_list() {
+ mocklog do_list "$@"
+ }
do_list_or_show() {
mocklog do_list_or_show "$@"
%text:expand >&2
@@ -606,11 +609,26 @@ Describe 'Command-Line Parsing'
The error should equal '$ do_tree /prefix -i pattern'
End
+ It 'interprets the raw list flag'
+ When call cmd_find -r pattern
+ The status should be success
+ The output should be blank
+ The error should equal '$ do_list pattern'
+ End
+
It 'reports a lack of argument'
cat() { @cat; }
When run cmd_find
The output should be blank
- The error should equal 'Usage: prg find [GREP_OPTIONS] regex'
+ The error should equal 'Usage: prg find [--raw,-r] [GREP_OPTIONS] regex'
+ The status should equal 1
+ End
+
+ It 'reports a lack of argument for grep'
+ cat() { @cat; }
+ When run cmd_find -r
+ The output should be blank
+ The error should equal 'Usage: prg find [--raw,-r] [GREP_OPTIONS] regex'
The status should equal 1
End
End
diff --git a/src/pashage.sh b/src/pashage.sh
@@ -1245,13 +1245,26 @@ cmd_edit() {
}
cmd_find() {
+ LIST_VIEW=no
+ case "${1-}" in
+ -r|--raw)
+ LIST_VIEW=yes
+ shift ;;
+ *)
+ ;;
+ esac
+
if [ $# -eq 0 ]; then
cmd_usage 'Usage: ' find >&2
exit 1
fi
- printf 'Search pattern: %s\n' "$*"
- do_tree "${PREFIX}" '' "$@"
+ if [ "${LIST_VIEW}" = yes ]; then
+ do_list '' "$@"
+ else
+ printf 'Search pattern: %s\n' "$*"
+ do_tree "${PREFIX}" '' "$@"
+ fi
}
cmd_generate() {
@@ -1742,7 +1755,7 @@ EOF
;;
find)
cat <<EOF
-${F}${PROGRAM} find [GREP_OPTIONS] regex
+${F}${PROGRAM} find [--raw,-r] [GREP_OPTIONS] regex
EOF
[ "${VERBOSE}" = yes ] && cat <<EOF
${I} List passwords that match the given regex.