Silence and document function
This commit is contained in:
committed by
greg-compass
parent
4fb00208f4
commit
8cbae36433
@@ -1,13 +1,16 @@
|
|||||||
# vim: set ft=python :
|
# vim: set ft=python :
|
||||||
|
|
||||||
def bw_unlock():
|
def bw_unlock():
|
||||||
|
"""Unlocks the BitWarden CLI and adds the resulting session code to the
|
||||||
|
current environment variables. Also returns the code for them."""
|
||||||
if "BW_SESSION" in ${...}:
|
if "BW_SESSION" in ${...}:
|
||||||
return $BW_SESSION
|
return $BW_SESSION
|
||||||
result = !(bw unlock)
|
result = $(bw unlock)
|
||||||
while not result:
|
while "BW_SESSION" not in result:
|
||||||
result = !(bw unlock)
|
result = $(bw unlock)
|
||||||
l = [k for k in result.lines if 'BW_SESSION="' in k][0]
|
lines = result.split("\n")
|
||||||
left, right = l.split("=")
|
l = [k for k in lines if 'BW_SESSION="' in k][0]
|
||||||
|
left, right = l.split("=", 1)
|
||||||
token = right[1:-1]
|
token = right[1:-1]
|
||||||
$BW_SESSION = token
|
$BW_SESSION = token
|
||||||
return token
|
return token
|
||||||
|
|||||||
Reference in New Issue
Block a user