Skip to content

Commit

Permalink
Merge pull request #5 from cjvirtucio87/options
Browse files Browse the repository at this point in the history
options
  • Loading branch information
cjvirtucio87 authored Dec 31, 2022
2 parents 34cc63f + f080a19 commit a0436ab
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion bwsh/bin/reset_password.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ set -eo pipefail
### pattern by default, per bitwarden-cli's behavior, unless
### EXACT_MATCH is set, in which case the item with the name
### as exactly typed is filtered for
### Options:
### EXACT_MATCH: if set to anything, looks up the one item that
### exactly matches the cred_name
### PW_OPTS: if set to a space-delimited list, use this list
### in the call to the password generation command
###
### Examples:
### # reset the password of any item with anything that
Expand All @@ -22,6 +27,10 @@ set -eo pipefail
### # exactly matches the word ally
### EXACT_MATCH=1 reset_password.sh ally
###
### # reset the password with custom password options (defaults are overriden)
### # exactly matches the word ally
### PW_OPTS='--uppercase --lowercase --special --number 30' reset_password.sh ally
###
### Remarks:
### This command is a pass-through to bitwarden CLI and uses jq
### to manipulate the items.
Expand Down Expand Up @@ -61,8 +70,14 @@ function main {

log "generating new password"

local pw_opts=(--uppercase --lowercase --special --number 20)
# shellcheck disable=SC2153
if [[ -n "${PW_OPTS}" ]]; then
read -ra pw_opts <<<"${PW_OPTS}"
fi

local new_pass
new_pass="$(bw generate password --uppercase --lowercase --special --number 20)"
new_pass="$(bw generate password "${pw_opts[@]}")"

local item_id
item_id="$(jq -r .id <<<"${json}")"
Expand Down

0 comments on commit a0436ab

Please sign in to comment.