diff --git a/src/commands/git_secret_cat.sh b/src/commands/git_secret_cat.sh new file mode 100644 index 00000000..128bd8f7 --- /dev/null +++ b/src/commands/git_secret_cat.sh @@ -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." +} diff --git a/src/commands/git_secret_usage.sh b/src/commands/git_secret_usage.sh index fa4e22e7..cbf1c17c 100644 --- a/src/commands/git_secret_usage.sh +++ b/src/commands/git_secret_usage.sh @@ -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]" }