add git secret cat filename [filename2] feature

pull/142/head
Josh Rabinowitz 6 years ago
parent c5ed5579f4
commit 40c63e9960

@ -0,0 +1,51 @@
#!/usr/bin/env bash
function cat {
local homedir=''
local passphrase=''
local force=0
OPTIND=1
while getopts 'hfd:p:' opt; do
case "$opt" in
h) _show_manual_for 'cat';;
f) force=1;;
p) passphrase=$OPTARG;;
d) homedir=$OPTARG;;
*) _invalid_option_for 'cat';;
esac
done
shift $((OPTIND-1))
[ "$1" = '--' ] && shift
_user_required
# Command logic:
local path_mappings
path_mappings=$(_get_secrets_dir_paths_mapping)
local counter=0
for line in "$@"
do
local filename
local path
echo $line
filename=$(_get_record_filename "$line")
path=$(_append_root_path "$filename")
# The parameters are: filename, write-to-file, force, homedir, passphrase
_decrypt "$path" "0" "$force" "$homedir" "$passphrase"
counter=$((counter+1))
done
#echo "done. all $counter files are revealed."
}

@ -19,7 +19,7 @@ function usage {
# to the old dynamic-loading version of this code.
# thanks to @antmak it is now fixed, see:
# https://github.com/sobolevn/git-secret/issues/47
local commands="add|changes|clean|hide|init|killperson|list|remove|reveal|tell|usage|whoknows"
local commands="add|cat|changes|clean|hide|init|killperson|list|remove|reveal|tell|usage|whoknows"
echo "usage: git secret [$commands]"
}

Loading…
Cancel
Save