Add terminal option

Adds ability to be used exclusively in the terminal by adding an
integer as the first command line argument (e.g., "dicekey 7").
This commit is contained in:
Kris Lamoureux 2016-11-10 21:00:26 -05:00
parent abeffc5fc2
commit 8a9e17ad0d
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
2 changed files with 24 additions and 11 deletions

View File

@ -25,7 +25,7 @@ from dicekey import diceware
class App:
def __init__(self, master):
def __init__(self, master, passgen):
frame = tk.Frame(master, padx=50, pady=50)
frame.pack()
@ -34,20 +34,33 @@ class App:
msg = tk.Label(frame, pady=15, font=("Arial", 16), text=msgtxt)
msg.pack()
pwgen = diceware.Gen()
if pwgen.loadlist("dicekey/wordlist.asc"):
passwd = ' '.join(pwgen.wordgen(7))
passwd = ' '.join(passgen.wordgen(7))
text = tk.Label(frame, font=("FreeMono", 16), text=passwd)
text.pack()
def main():
pwgen = diceware.Gen()
wordlist = pwgen.loadlist("dicekey/wordlist.asc")
if len(sys.argv) > 1:
if wordlist:
if sys.argv[1].isdigit():
print ' '.join(pwgen.wordgen(int(sys.argv[1])))
else:
error = "Error: Argument '%s' is not an integer."
print error % (sys.argv[1])
else:
print "Error: Incomplete or missing word list."
else:
root = tk.Tk()
root.wm_title("Dicekey - Passphrase Generator")
app = App(root)
app = App(root, pwgen)
root.mainloop()
sys.exit(0)

View File

@ -17,7 +17,7 @@
from distutils.core import setup
NAME = "Dicekey"
VERSION = "3.0.0-prealpha"
VERSION = "3.1.0-prealpha"
AUTHOR = "Kris Lamoureux"
AUTHOR_EMAIL = "KrisPublicEmail@gmail.com"
URL = "https://github.com/Kris619/Dicekey/"