Skip to content

Commit

Permalink
Copying related improvement
Browse files Browse the repository at this point in the history
Copy password to clipboard after --
* new password creation
* without printing it on screen
  • Loading branch information
Yadnyawalk Tale committed Feb 9, 2020
1 parent 01bedac commit e3fc379
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions pygenpass/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import click

from pygenpass.password import allpass
from pygenpass.password import copypass
from pygenpass.password import createpass
from pygenpass.password import delpass
from pygenpass.password import modpass
Expand All @@ -42,6 +43,7 @@ def main():
main.add_command(savepass)
main.add_command(delpass)
main.add_command(version)
main.add_command(copypass)

if __name__ == "__main__":
main()
16 changes: 12 additions & 4 deletions pygenpass/password.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
from datetime import date
import click # Used for command line interface
import diceware # Used for creating password
import pyperclip

import click
import diceware
from beautifultable import BeautifulTable

from datetime import date
from pygenpass.database import DatabaseConnection

db_obj = DatabaseConnection()
Expand Down Expand Up @@ -96,6 +96,7 @@ def createpass():
"""Used for taking input from user to create password"""
portal_name = click.prompt("Enter portal name", default="None")
password = diceware.get_passphrase()
pyperclip.copy(password)
creation_date = date.today()
email = click.prompt("Enter email id", default="None")
portal_url = click.prompt("Enter portal url", default="None")
Expand All @@ -116,3 +117,10 @@ def showpass():
print("No records found")
else:
print(spass)


@click.command("copy", help="Copy password")
@click.argument("portal_name")
def copypass(portal_name):
password = db_obj.show_data(portal_name)
pyperclip.copy(password)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ diceware>=0.9.6
click>=7.0
beautifultable>=0.5.0
setuptools>=40.0.0
pyperclip>=1.7.0
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ install_requires =
beautifultable
click
diceware
pyperclip

[options.entry_points]
console_scripts =
Expand Down

0 comments on commit e3fc379

Please sign in to comment.