@@ -36,6 +36,7 @@ LastPass CLI in Python. Very Minimal.
3636---------------------------------------------
3737"""
3838
39+ from __future__ import print_function
3940import argparse
4041import getpass
4142import json
@@ -68,8 +69,8 @@ S_WHITE = '\033[37m'
6869S_RESET = '\033 [0m'
6970
7071LPASS_ENCRYPTION_KEY = '1234567890ABCDEF'
71- LPASS_CONFIG_FILE = os .path .expanduser ("~/.lpass-config" )
72- LPASS_BLOB_FILE = os .path .expanduser ("~/.lpass-blob" )
72+ LPASS_CONFIG_FILE = os .getenv ( 'LPASS_CONFIG_FILE' , os . path .expanduser ("~/.lpass-config" ) )
73+ LPASS_BLOB_FILE = os .getenv ( 'LPASS_BLOB_FILE' , os . path .expanduser ("~/.lpass-blob" ) )
7374CLIENT_ID = None # Usually the IMEI.
7475
7576
@@ -138,7 +139,7 @@ def command_login(args):
138139 if os .path .exists (LPASS_CONFIG_FILE ):
139140 if not args .force :
140141 raise Exception ('Unable to Overwrite Configuration.' )
141- (_ , password ) = __get_login (args .username , None , args .mfa )
142+ (_ , password ) = __get_login (args .username , os . getenv ( 'LPASS_PASSWORD' , None ) , args .mfa )
142143 __print_message ('Logged into {}' .format (__colored (args .username , S_YELLOW )))
143144 __write_config (args .username , password , args .mfa )
144145
@@ -273,7 +274,7 @@ def main():
273274 parser_login .add_argument ('--plaintext-key' , default = True , action = 'store_true' )
274275 parser_login .add_argument ('--mfa' , default = False , action = 'store_true' )
275276 parser_login .add_argument ('--force' , '-f' , default = False , action = 'store_true' )
276- parser_login .add_argument ('username' , type = str , default = None )
277+ parser_login .add_argument ('username' , type = str , default = os . getenv ( 'LPASS_USER' , None ) )
277278 parser_login .set_defaults (func = command_login )
278279
279280 parser_logout = subparsers .add_parser ('logout' , help = 'Logout from Lasspass.' )
0 commit comments