diff options
author | Christian Cleberg <hello@cleberg.net> | 2025-04-05 13:36:49 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-05 13:36:49 -0500 |
commit | c8617ce8aecb40ccf1d13c02dcd7d7e74e79b56b (patch) | |
tree | cf901030197768b2aa21d2d3fcf0426948a94111 /yoshi/cli.py | |
parent | 1fc982100a13de26bfca3419d1a6c5a65acad3d2 (diff) | |
download | yoshi-cli-c8617ce8aecb40ccf1d13c02dcd7d7e74e79b56b.tar.gz yoshi-cli-c8617ce8aecb40ccf1d13c02dcd7d7e74e79b56b.tar.bz2 yoshi-cli-c8617ce8aecb40ccf1d13c02dcd7d7e74e79b56b.zip |
migrate from pylint to ruff-action (#4)
* migrate from pylint to ruff-action
* temporarily disable push param
* Commit from GitHub Actions (Pylint)
* re-enable push param
---------
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'yoshi/cli.py')
-rw-r--r-- | yoshi/cli.py | 90 |
1 files changed, 38 insertions, 52 deletions
diff --git a/yoshi/cli.py b/yoshi/cli.py index e140098..2e9ce49 100644 --- a/yoshi/cli.py +++ b/yoshi/cli.py @@ -7,91 +7,76 @@ It imports the required modules and sets up a parser with basic options for demo import argparse from yoshi import crypto, database, process + def yoshi(): """ CLI entry point logic, used to parse user inputs. """ parser = argparse.ArgumentParser( - description='Manage your username and passwords via a convenient CLI vault.' + description="Manage your username and passwords via a convenient CLI vault." ) # Top-level arguments group_one = parser.add_mutually_exclusive_group() group_one.add_argument( - '-n', '--new', - help='Create a new account.', - action='store_true' + "-n", "--new", help="Create a new account.", action="store_true" ) group_one.add_argument( - '-l', '--list', - help='List all saved accounts.', - action='store_true' + "-l", "--list", help="List all saved accounts.", action="store_true" ) group_one.add_argument( - '-e', '--edit', - help='Edit a saved account.', - action='store_true' + "-e", "--edit", help="Edit a saved account.", action="store_true" ) group_one.add_argument( - '-d', '--delete', - help='Delete a saved account.', - action='store_true' + "-d", "--delete", help="Delete a saved account.", action="store_true" ) group_one.add_argument( - '--purge', + "--purge", help=( - 'Purge all accounts and delete the vault. ' - '(Caution: this will irreversibly destroy your data.)' + "Purge all accounts and delete the vault. " + "(Caution: this will irreversibly destroy your data.)" ), - action='store_true' - ) - group_one.add_argument( - '--encrypt', - help='Encrypt the vault.', - action='store_true' - ) - group_one.add_argument( - '--decrypt', - help='Decrypt the vault.', - action='store_true' + action="store_true", ) + group_one.add_argument("--encrypt", help="Encrypt the vault.", action="store_true") + group_one.add_argument("--decrypt", help="Decrypt the vault.", action="store_true") # Encryption flags group_two = parser.add_mutually_exclusive_group() group_two.add_argument( - '-g', '--generate', - help=( - 'When using the --encrypt option, generate a new encryption key.' - ), - action='store_true' + "-g", + "--generate", + help=("When using the --encrypt option, generate a new encryption key."), + action="store_true", ) group_two.add_argument( - '-k', '--keyfile', - help='Path to existing key file.', - action='store', + "-k", + "--keyfile", + help="Path to existing key file.", + action="store", nargs=1, - type=str + type=str, ) # Edit flags group_three = parser.add_argument_group() group_three.add_argument( - '-u', '--uuid', - help=( - 'When using the --edit or --delete options, provide the account UUID.' - ), - action='store', + "-u", + "--uuid", + help=("When using the --edit or --delete options, provide the account UUID."), + action="store", nargs=1, - type=str + type=str, ) group_three.add_argument( - '-f', '--field', + "-f", + "--field", help=( - 'When using the --edit option, specify the field to edit (integer index).' + "When using the --edit option, specify the field to edit (integer index)." ), - action='store', + action="store", nargs=1, - type=int + type=int, ) args = parser.parse_args() @@ -100,22 +85,22 @@ def yoshi(): if args.keyfile: key = crypto.load_key(args.keyfile[0]) else: - key = input('Please enter your decryption key: ') + key = input("Please enter your decryption key: ") crypto.decrypt(key) elif args.encrypt: if args.generate: key = crypto.generate_key() print( - 'WRITE THIS KEY DOWN SOMEWHERE SAFE. YOU WILL NOT BE ABLE TO DECRYPT ' - 'YOUR DATA WITHOUT IT!' + "WRITE THIS KEY DOWN SOMEWHERE SAFE. YOU WILL NOT BE ABLE TO DECRYPT " + "YOUR DATA WITHOUT IT!" ) print(key.decode()) - print('\n') + print("\n") else: if args.keyfile: key = crypto.load_key(args.keyfile[0]) else: - key = input('Please enter your encryption key: ') + key = input("Please enter your encryption key: ") crypto.encrypt(key) elif database.check_table(): if args.new: @@ -130,8 +115,9 @@ def yoshi(): process.purge_accounts() else: raise TypeError( - 'Please specify a command or use the --help flag for more information.' + "Please specify a command or use the --help flag for more information." ) + if __name__ == "__main__": yoshi() |