mirror of
https://github.com/hughrun/ephemetoot
synced 2025-02-16 19:50:35 +01:00
Add --version flag
Commit adds a --version flag to display the current version (from setup.py) and also fetch the latest version (from the git repo). Additionally includes the version number in the header when running deletions. Resolves #27
This commit is contained in:
parent
c4c7b11fba
commit
a1db933bbd
@ -30,10 +30,14 @@ import yaml
|
||||
from argparse import ArgumentParser
|
||||
from datetime import datetime, timezone
|
||||
import os
|
||||
import pkg_resources
|
||||
|
||||
# local files
|
||||
from lib import ephemetoot
|
||||
|
||||
# version number from setup.py
|
||||
vnum = pkg_resources.require("ephemetoot")[0].version
|
||||
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--config", action="store", metavar="'filepath'", default="config.yaml", help="Filepath of your config file, relative to the current directory. If no --config path is provided, ephemetoot will use 'config.yaml'."
|
||||
@ -56,6 +60,9 @@ parser.add_argument(
|
||||
parser.add_argument(
|
||||
"--time", action="store", metavar="'hours minutes'", nargs="*", help="Hour and minute to schedule: e.g. 9 30 for 9.30am"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--version", action="store_true", help="Display the version number"
|
||||
)
|
||||
|
||||
options = parser.parse_args()
|
||||
if options.config[0] == '~':
|
||||
@ -66,13 +73,15 @@ else:
|
||||
config_file = os.path.join( os.getcwd(), options.config )
|
||||
|
||||
if __name__ == "__main__":
|
||||
if options.schedule:
|
||||
if options.version:
|
||||
ephemetoot.version(vnum)
|
||||
elif options.schedule:
|
||||
ephemetoot.schedule(options)
|
||||
else:
|
||||
print('')
|
||||
print('============= EPHEMETOOT ================')
|
||||
print('============= EPHEMETOOT v' + vnum + ' ================')
|
||||
print('Running at ' + str( datetime.now(timezone.utc).strftime('%a %d %b %Y %H:%M:%S %z') ))
|
||||
print('=========================================')
|
||||
print('================================================')
|
||||
print('')
|
||||
if options.test:
|
||||
print("This is a test run...")
|
||||
|
@ -7,6 +7,18 @@ import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
def version(vnum):
|
||||
try:
|
||||
latest = requests.get('https://api.github.com/repos/hughrun/ephemetoot/releases/latest')
|
||||
res = latest.json()
|
||||
latest_version = res['name']
|
||||
print('\nYou are using ephemetoot Version ' + vnum)
|
||||
print('The latest release is ' + latest_version + '\n')
|
||||
|
||||
except Exception as e:
|
||||
print('Something went wrong:')
|
||||
print(e)
|
||||
|
||||
def schedule(options):
|
||||
try:
|
||||
with open(options.schedule + '/ephemetoot.scheduler.plist', 'r') as file:
|
||||
|
4
setup.py
4
setup.py
@ -1,7 +1,7 @@
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(name='ephemetoot',
|
||||
version='2.1.0',
|
||||
version='2.3.1',
|
||||
url='https://github.com/hughrun/ephemetoot',
|
||||
license='GPL-3.0-or-later',
|
||||
packages=find_packages(),
|
||||
@ -10,7 +10,7 @@ setup(name='ephemetoot',
|
||||
zip_safe=False,
|
||||
author='Hugh Rundle',
|
||||
author_email='hugh@hughrundle.net',
|
||||
description='A command line tool for selectively deleting old toots.',
|
||||
description='A command line tool for selectively deleting old toots from one or more Mastodon accounts.',
|
||||
keywords='mastodon, mastodon api',
|
||||
project_urls={
|
||||
'Source Code': 'https://github.com/hughrun/ephemetoot',
|
||||
|
Loading…
x
Reference in New Issue
Block a user