Compare commits

...

4 Commits
master ... cli

Author SHA1 Message Date
e120815378 splits main function and parser 2022-01-16 22:22:19 +01:00
3a47ee56bf updates setup.py for cli 2022-01-16 22:18:12 +01:00
aeca052cbc adds cli to __init__ 2022-01-16 19:57:19 +01:00
2294650daa 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
2022-01-16 19:52:12 +01:00
4 changed files with 33 additions and 7 deletions

View File

@ -1,2 +1,3 @@
from bump.bump import Bump from bump.bump import Bump
import bump.cli as cli

View File

@ -6,6 +6,7 @@ import requests
import base64 import base64
import re import re
import os import os
import typer
from random_word import RandomWords from random_word import RandomWords
SENDER_LENGTH = 4 SENDER_LENGTH = 4
@ -58,7 +59,6 @@ class Bump:
if self.secrets == []: if self.secrets == []:
print("you seem to not have a secret in your secrets file! Creating one now...") print("you seem to not have a secret in your secrets file! Creating one now...")
self.generate_secret(secrets_file) self.generate_secret(secrets_file)
self.show_secret()
self.URL = "https://bump.maenle.net/api/" self.URL = "https://bump.maenle.net/api/"
@ -215,7 +215,3 @@ class Bump:
self._save_log(message) self._save_log(message)
log = self.load_log() log = self.load_log()
if __name__ == '__main__':
b = Bump()

23
bump/cli.py Normal file
View File

@ -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()

View File

@ -1,10 +1,15 @@
from setuptools import setup from setuptools import setup
setup( setup(
entry_points={
'console_scripts': [
'bump = bump.cli:main',
],
},
name='bump_python', name='bump_python',
packages=['bump'], packages=['bump'],
description='Notify your Phone from Python', description='Notify your Phone from Python',
version='0.1.1', version='0.1.2',
url='https://git.maenle.tech/raphael/bump_python', url='https://git.maenle.tech/raphael/bump_python',
author='Raphael Maenle', author='Raphael Maenle',
author_email='raphael@maenle.net', author_email='raphael@maenle.net',
@ -18,6 +23,7 @@ setup(
'qrcode', 'qrcode',
'pyyaml', 'pyyaml',
'random-word', 'random-word',
'cryptography' 'cryptography',
'typer'
] ]
) )