From 750f79f03a03e196c4146a6eaa2f819a3acec966 Mon Sep 17 00:00:00 2001 From: raphael Date: Sun, 16 Jan 2022 22:24:23 +0100 Subject: [PATCH] adds minimal cli for qr code and pushing - cli generated using typer package, which is added to the setup.py - if optional argument to bump is not passed, the current secret is visualized - if there is an argument, it is pushed as a message to the current sender - adds setup.py command line script which adds a call to the bump.cli:main function passing the cli parameters along - updates package version to 0.1.3 - Squashed commits: - commit e12081537853250e26602bfbed73e41561392785 - commit 3a47ee56bf94859ef4b5521405bb6971c7d6dcac - commit aeca052cbccb31c5a78ef5bd94e3be1d2e1193bc - commit 2294650daa7c2ea9ac64b66fd99c4706c7d70a2f --- bump/__init__.py | 1 + bump/bump.py | 6 +----- bump/cli.py | 23 +++++++++++++++++++++++ setup.py | 10 ++++++++-- 4 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 bump/cli.py diff --git a/bump/__init__.py b/bump/__init__.py index 7a74295..16d3c96 100644 --- a/bump/__init__.py +++ b/bump/__init__.py @@ -1,2 +1,3 @@ from bump.bump import Bump +import bump.cli as cli diff --git a/bump/bump.py b/bump/bump.py index b880746..36382f8 100644 --- a/bump/bump.py +++ b/bump/bump.py @@ -6,6 +6,7 @@ import requests import base64 import re import os +import typer from random_word import RandomWords SENDER_LENGTH = 4 @@ -58,7 +59,6 @@ class Bump: if self.secrets == []: print("you seem to not have a secret in your secrets file! Creating one now...") self.generate_secret(secrets_file) - self.show_secret() self.URL = "https://bump.maenle.net/api/" @@ -215,7 +215,3 @@ class Bump: self._save_log(message) log = self.load_log() - - -if __name__ == '__main__': - b = Bump() diff --git a/bump/cli.py b/bump/cli.py new file mode 100644 index 0000000..7b90b10 --- /dev/null +++ b/bump/cli.py @@ -0,0 +1,23 @@ +import bump +import typer + +cli = typer.Typer() + +@cli.command() +def default(message = typer.Argument(None, help="The message to be bumped")): + bp = bump.Bump() + if message is None: + bp.show_secret() + else: + bp.push(message) + +@cli.command() +def push(): + bp = bump.Bump() + bp.version() + +def main(): + typer.run(default) + +if __name__ == "__main__": + main() diff --git a/setup.py b/setup.py index 0d4a40f..5719074 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,15 @@ from setuptools import setup setup( + entry_points={ + 'console_scripts': [ + 'bump = bump.cli:main', + ], + }, name='bump_python', packages=['bump'], description='Notify your Phone from Python', - version='0.1.1', + version='0.1.3', url='https://git.maenle.tech/raphael/bump_python', author='Raphael Maenle', author_email='raphael@maenle.net', @@ -18,6 +23,7 @@ setup( 'qrcode', 'pyyaml', 'random-word', - 'cryptography' + 'cryptography', + 'typer' ] )