mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-05 16:47:14 -04:00
Combined print functions
This commit is contained in:
+79
-97
@@ -106,52 +106,82 @@ def tweak(): # runs configuration wizard
|
|||||||
print('\nConfiguration complete!\n')
|
print('\nConfiguration complete!\n')
|
||||||
|
|
||||||
|
|
||||||
def helper(): # displays help menu
|
def print_info(): # prints help text based on argument
|
||||||
print('\nsshyp Copyright (C) 2021 Randall Winkhart')
|
if argument == 'help' or argument == '--help' or argument == '-h':
|
||||||
print("This is free software, and you are welcome to redistribute it under certain conditions;\nthis program comes "
|
print('\nsshyp Copyright (C) 2021 Randall Winkhart')
|
||||||
"with ABSOLUTELY NO WARRANTY;\ntype `sshyp license' for details.")
|
print("This is free software, and you are welcome to redistribute it under certain conditions;\nthis program "
|
||||||
print('\nUSAGE: sshyp [/<entry name>] [OPTION] [FLAG]\n')
|
"comes with ABSOLUTELY NO WARRANTY;\ntype `sshyp license' for details.")
|
||||||
print('Options: ')
|
print('\nUSAGE: sshyp [/<entry name>] [OPTION] [FLAG]\n')
|
||||||
print('help/--help/-h bring up this menu')
|
print('Options: ')
|
||||||
print('version/-v display sshyp version info')
|
print('help/--help/-h bring up this menu')
|
||||||
print('tweak configure sshyp')
|
print('version/-v display sshyp version info')
|
||||||
print('add add an entry')
|
print('tweak configure sshyp')
|
||||||
print('gen generate a new password')
|
print('add add an entry')
|
||||||
print('edit edit an existing entry')
|
print('gen generate a new password')
|
||||||
print('copy copy details of an entry to your clipboard')
|
print('edit edit an existing entry')
|
||||||
print('shear/-rm delete an existing entry')
|
print('copy copy details of an entry to your clipboard')
|
||||||
print('sync/-s manually sync the entry directory via sshync\n')
|
print('shear/-rm delete an existing entry')
|
||||||
print('Flags:')
|
print('sync/-s manually sync the entry directory via sshync\n')
|
||||||
print('add:')
|
print('Flags:')
|
||||||
print(' password/-p add a password entry')
|
print('add:')
|
||||||
print(' note/-n add a note entry')
|
print(' password/-p add a password entry')
|
||||||
print(' folder/-f add a new folder for entries')
|
print(' note/-n add a note entry')
|
||||||
print('edit:')
|
print(' folder/-f add a new folder for entries')
|
||||||
print(' rename/relocate/-r rename or relocate an entry')
|
print('edit:')
|
||||||
print(' username/-u change the username of an entry')
|
print(' rename/relocate/-r rename or relocate an entry')
|
||||||
print(' password/-p change the password of an entry')
|
print(' username/-u change the username of an entry')
|
||||||
print(' note/-n change the note attached to an entry')
|
print(' password/-p change the password of an entry')
|
||||||
print(' url/-l change the url attached to an entry')
|
print(' note/-n change the note attached to an entry')
|
||||||
print('copy:')
|
print(' url/-l change the url attached to an entry')
|
||||||
print(' username/-u copy the username of an entry to your clipboard')
|
print('copy:')
|
||||||
print(' password/-p copy the password of an entry to your clipboard')
|
print(' username/-u copy the username of an entry to your clipboard')
|
||||||
print(' url/-l copy the URL of an entry to your clipboard')
|
print(' password/-p copy the password of an entry to your clipboard')
|
||||||
print(' note/-n copy the note of an entry to your clipboard')
|
print(' url/-l copy the URL of an entry to your clipboard')
|
||||||
print('gen:')
|
print(' note/-n copy the note of an entry to your clipboard')
|
||||||
print(' update/-u generate a password for an existing entry\n')
|
print('gen:')
|
||||||
print("Tip: You can quickly read an entry with 'sshyp /<entry name>'!")
|
print(' update/-u generate a password for an existing entry\n')
|
||||||
print("When specifying entry names, do not include the file extension! '.gpg' is assumed!\n")
|
print("Tip: You can quickly read an entry with 'sshyp /<entry name>'!")
|
||||||
|
print("When specifying entry names, do not include the file extension! '.gpg' is assumed!\n")
|
||||||
|
elif argument == 'version' or argument == '-v':
|
||||||
def version(): # displays version information
|
print('\n////////////////////////////////////////////////////////')
|
||||||
print('\n////////////////////////////////////////////////////////')
|
print('/ /')
|
||||||
print('/ /')
|
print('/ sshyp Copyright (C) 2021 Randall Winkhart /')
|
||||||
print('/ sshyp Copyright (C) 2021 Randall Winkhart /')
|
print('/ /')
|
||||||
print('/ /')
|
print('/ Version 2022.01.10.fr2.3 /')
|
||||||
print('/ Version 2022.01.10.fr2.3 /')
|
print('/ The Lighter Update /')
|
||||||
print('/ The Lighter Update /')
|
print('/ /')
|
||||||
print('/ /')
|
print('////////////////////////////////////////////////////////\n')
|
||||||
print('////////////////////////////////////////////////////////\n')
|
elif argument == 'license':
|
||||||
|
print('\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU '
|
||||||
|
'General\nPublic License as published by the Free Software Foundation, either version 3 of the License,'
|
||||||
|
'\nor (at your option) any later version.\n\nThis program is distributed in the hope that it will be '
|
||||||
|
'useful, but WITHOUT ANY WARRANTY;\nwithout even the implied warranty of MERCHANTABILITY or FITNESS FOR A'
|
||||||
|
' PARTICULAR PURPOSE.\nSee the GNU General Public License for more details.'
|
||||||
|
'\n\nhttps://opensource.org/licenses/GPL-3.0\n')
|
||||||
|
elif argument == 'add':
|
||||||
|
print('\nUSAGE: sshyp add [FLAG]')
|
||||||
|
print('Flags:')
|
||||||
|
print('add:')
|
||||||
|
print(' password/-p add a password entry')
|
||||||
|
print(' note/-n add a note entry')
|
||||||
|
print(' folder/-f add a new folder for entries\n')
|
||||||
|
elif argument == 'edit':
|
||||||
|
print('\nUSAGE: sshyp edit [FLAG]')
|
||||||
|
print('Flags:')
|
||||||
|
print('edit:')
|
||||||
|
print(' rename/relocate/-r rename or relocate an entry')
|
||||||
|
print(' username/-u change the username of an entry')
|
||||||
|
print(' password/-p change the password of an entry')
|
||||||
|
print(' url/-l change the url attached to an entry')
|
||||||
|
print(' note/-n change the note attached to an entry\n')
|
||||||
|
elif argument == 'copy':
|
||||||
|
print('\nUSAGE: sshyp copy [FLAG]')
|
||||||
|
print('Flags:')
|
||||||
|
print('copy:')
|
||||||
|
print(' username/-u copy the username of an entry to your clipboard')
|
||||||
|
print(' password/-p copy the password of an entry to your clipboard')
|
||||||
|
print(' url/-l copy the URL of an entry to your clipboard')
|
||||||
|
print(' note/-n copy the note of an entry to your clipboard\n')
|
||||||
|
|
||||||
|
|
||||||
def no_arg(): # displays a list of entries and gives an option to select one for viewing
|
def no_arg(): # displays a list of entries and gives an option to select one for viewing
|
||||||
@@ -162,15 +192,6 @@ def no_arg(): # displays a list of entries and gives an option to select one fo
|
|||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
def show_license(): # displays licensing information
|
|
||||||
print('\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General'
|
|
||||||
'\nPublic License as published by the Free Software Foundation, either version 3 of the License,\nor '
|
|
||||||
'(at your option) any later version.\n'
|
|
||||||
'\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\nwithout even '
|
|
||||||
'the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU General Public '
|
|
||||||
'License for more details.\n\nhttps://opensource.org/licenses/GPL-3.0\n')
|
|
||||||
|
|
||||||
|
|
||||||
def read_shortcut(): # shortcut to quickly read an entry
|
def read_shortcut(): # shortcut to quickly read an entry
|
||||||
system(f"gpg -d '{directory}{argument.replace('/', '', 1)}.gpg'")
|
system(f"gpg -d '{directory}{argument.replace('/', '', 1)}.gpg'")
|
||||||
|
|
||||||
@@ -183,15 +204,6 @@ def sync(): # calls sshync to sync changes to the user's server
|
|||||||
sshync.run_profile('/var/lib/sshyp/sshyp.sshync')
|
sshync.run_profile('/var/lib/sshyp/sshyp.sshync')
|
||||||
|
|
||||||
|
|
||||||
def add_info(): # displays 'add' syntax
|
|
||||||
print('\nUSAGE: sshyp add [FLAG]')
|
|
||||||
print('Flags:')
|
|
||||||
print('add:')
|
|
||||||
print(' password/-p add a password entry')
|
|
||||||
print(' note/-n add a note entry')
|
|
||||||
print(' folder/-f add a new folder for entries\n')
|
|
||||||
|
|
||||||
|
|
||||||
def add_entry(): # adds a new entry
|
def add_entry(): # adds a new entry
|
||||||
_entry_name = str(input('\nName of entry: '))
|
_entry_name = str(input('\nName of entry: '))
|
||||||
if _entry_name.startswith('/'):
|
if _entry_name.startswith('/'):
|
||||||
@@ -223,17 +235,6 @@ def add_folder(): # creates a new folder
|
|||||||
system(f"ssh -p {port} {username_ssh}@{ip} \"mkdir -p '{directory_ssh}{_folder_name}'\"")
|
system(f"ssh -p {port} {username_ssh}@{ip} \"mkdir -p '{directory_ssh}{_folder_name}'\"")
|
||||||
|
|
||||||
|
|
||||||
def edit_info(): # displays 'edit' syntax
|
|
||||||
print('\nUSAGE: sshyp edit [FLAG]')
|
|
||||||
print('Flags:')
|
|
||||||
print('edit:')
|
|
||||||
print(' rename/relocate/-r rename or relocate an entry')
|
|
||||||
print(' username/-u change the username of an entry')
|
|
||||||
print(' password/-p change the password of an entry')
|
|
||||||
print(' url/-l change the url attached to an entry')
|
|
||||||
print(' note/-n change the note attached to an entry\n')
|
|
||||||
|
|
||||||
|
|
||||||
def rename(): # renames an entry or folder TODO delete original from server to prevent re-downloading
|
def rename(): # renames an entry or folder TODO delete original from server to prevent re-downloading
|
||||||
print()
|
print()
|
||||||
system(f"cd {directory}; ls -1 *") # TODO replace with new list
|
system(f"cd {directory}; ls -1 *") # TODO replace with new list
|
||||||
@@ -308,16 +309,6 @@ def gen(): # generates a password for a new or an existing entry
|
|||||||
system(f"gpg -d '{directory}{_entry_name}.gpg'")
|
system(f"gpg -d '{directory}{_entry_name}.gpg'")
|
||||||
|
|
||||||
|
|
||||||
def copy_info(): # displays 'copy' syntax
|
|
||||||
print('\nUSAGE: sshyp copy [FLAG]')
|
|
||||||
print('Flags:')
|
|
||||||
print('copy:')
|
|
||||||
print(' username/-u copy the username of an entry to your clipboard')
|
|
||||||
print(' password/-p copy the password of an entry to your clipboard')
|
|
||||||
print(' url/-l copy the URL of an entry to your clipboard')
|
|
||||||
print(' note/-n copy the note of an entry to your clipboard\n')
|
|
||||||
|
|
||||||
|
|
||||||
def copy_data(): # copies a specified field of an entry to the clipboard
|
def copy_data(): # copies a specified field of an entry to the clipboard
|
||||||
print()
|
print()
|
||||||
system(f"cd {directory}; ls -1 *") # TODO replace with new list
|
system(f"cd {directory}; ls -1 *") # TODO replace with new list
|
||||||
@@ -412,14 +403,9 @@ elif argument == '':
|
|||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('\n')
|
print('\n')
|
||||||
s_exit()
|
s_exit()
|
||||||
elif argument == 'help' or argument == '--help' or argument == '-h':
|
elif argument == 'help' or argument == '--help' or argument == '-h' or argument == 'license' or argument == 'version' \
|
||||||
helper()
|
or argument == '-v' or argument == 'add' or argument == 'edit' or argument == 'copy':
|
||||||
elif argument == 'license':
|
print_info()
|
||||||
show_license()
|
|
||||||
elif argument == 'version' or argument == '-v':
|
|
||||||
version()
|
|
||||||
elif argument == 'add':
|
|
||||||
add_info()
|
|
||||||
elif argument == 'add note' or argument == 'add -n' or argument == 'add password' or argument == 'add -p':
|
elif argument == 'add note' or argument == 'add -n' or argument == 'add password' or argument == 'add -p':
|
||||||
try:
|
try:
|
||||||
add_entry()
|
add_entry()
|
||||||
@@ -432,8 +418,6 @@ elif argument == 'add folder' or argument == 'add -f':
|
|||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('\n')
|
print('\n')
|
||||||
s_exit()
|
s_exit()
|
||||||
elif argument == 'edit':
|
|
||||||
edit_info()
|
|
||||||
elif argument == 'edit rename' or argument == 'edit relocate' or argument == 'edit -r':
|
elif argument == 'edit rename' or argument == 'edit relocate' or argument == 'edit -r':
|
||||||
try:
|
try:
|
||||||
rename()
|
rename()
|
||||||
@@ -453,8 +437,6 @@ elif argument == 'gen' or argument == 'gen update' or argument == 'gen -u':
|
|||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('\n')
|
print('\n')
|
||||||
s_exit()
|
s_exit()
|
||||||
elif argument == 'copy':
|
|
||||||
copy_info()
|
|
||||||
elif argument == 'copy username' or argument == 'copy -u' or argument == 'copy password' or argument == 'copy -p' or \
|
elif argument == 'copy username' or argument == 'copy -u' or argument == 'copy password' or argument == 'copy -p' or \
|
||||||
argument == 'copy url' or argument == 'copy -l' or argument == 'copy note' or argument == 'copy -n':
|
argument == 'copy url' or argument == 'copy -l' or argument == 'copy note' or argument == 'copy -n':
|
||||||
try:
|
try:
|
||||||
@@ -10,7 +10,7 @@ New features:
|
|||||||
Changes:
|
Changes:
|
||||||
|
|
||||||
** the gen command in sshyp has been updated to use the newer notetaking system
|
** the gen command in sshyp has been updated to use the newer notetaking system
|
||||||
** printing functions in sshyp have been combined into one function (arguments determine section to print)
|
- printing functions in sshyp have been combined into one function (arguments determine section to print)
|
||||||
** file not found exceptions have been re-implemented
|
** file not found exceptions have been re-implemented
|
||||||
** when syncing, a check is made to see if any folders are not on all devices - if the check comes back true, it is corrected
|
** when syncing, a check is made to see if any folders are not on all devices - if the check comes back true, it is corrected
|
||||||
** folders generated in /dev/shm are once again properly deleted with keyboard interrupts
|
** folders generated in /dev/shm are once again properly deleted with keyboard interrupts
|
||||||
|
|||||||
Reference in New Issue
Block a user