archive
/
actioner
Archived
1
Fork 0

Swap out argparse for click

This commit is contained in:
Jake Howard 2019-09-19 08:52:36 +01:00
parent 6450c6dc57
commit aedda06ace
Signed by: jake
GPG Key ID: 57AFB45680EDD477
4 changed files with 24 additions and 21 deletions

View File

@ -19,7 +19,8 @@ ipython = "*"
python_version = "3.7"
[scripts]
start = "python3 -m actioner"
start = "python3 -m actioner start"
actioner = "python3 -m actioner"
test-fix = "bash ./scripts/test-fix.sh"
test = "bash ./scripts/test.sh"
@ -36,3 +37,4 @@ starlette = "*"
uvicorn = "*"
starlette-auth-toolkit = "*"
sentry-asgi = "*"
click = "*"

18
Pipfile.lock generated
View File

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "9d8b929fb9ddb12e7e7b61c48f3ca46bf5e5fc83f8892e754d57639303185225"
"sha256": "68b011f9a94c0e9b4abd73c6516f180575182b01c15108f29d1c286c5d53d733"
},
"pipfile-spec": 6,
"requires": {
@ -26,10 +26,10 @@
},
"certifi": {
"hashes": [
"sha256:046832c04d4e752f37383b628bc601a7ea7211496b4638f6514d0e5b9acc4939",
"sha256:945e3ba63a0b9f577b1395204e13c3a231f9bc0223888be653286534e5873695"
"sha256:e4f3620cfea4f83eedc95b24abd9cd56f3c4b146dd0177e83a21b4eb49e21e50",
"sha256:fd7c7c74727ddcf00e9acd26bba8da604ffec95bf1c2144e67aff7a8b50e6cef"
],
"version": "==2019.6.16"
"version": "==2019.9.11"
},
"chardet": {
"hashes": [
@ -43,6 +43,7 @@
"sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13",
"sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"
],
"index": "pypi",
"version": "==7.0"
},
"deprecated": {
@ -63,6 +64,7 @@
"hashes": [
"sha256:e00cbd7ba01ff748e494248183abc6e153f49181169d8a3d41bb49132ca01dfc"
],
"markers": "sys_platform != 'win32' and sys_platform != 'cygwin' and platform_python_implementation != 'pypy'",
"version": "==0.0.13"
},
"idna": {
@ -117,11 +119,11 @@
},
"sentry-sdk": {
"hashes": [
"sha256:528f936118679e9a52dacb96bfefe20acb5d63e0797856c64a582cc3c2bc1f9e",
"sha256:b4edcb1296fee107439345d0f8b23432b8732b7e28407f928367d0a4a36301a9"
"sha256:01c8b27233c792d7d957cefd0e261d7913e1633a7d8a67ad1df742cb9f2b50a5",
"sha256:13e58855d6e347f8545c7f18ae4db3d56639540f21e4476d94c8fc16a0af57ca"
],
"index": "pypi",
"version": "==0.11.2"
"version": "==0.12.0"
},
"six": {
"hashes": [
@ -183,6 +185,7 @@
"sha256:c63b6c0bf33144c604dd72f7eecf2d3a3ac7405c503c67bd98128cf306efe18a",
"sha256:e698a20a3b4ccb380d207f9d491d4085d7c38d364f6a0bae98684a1612a9607a"
],
"markers": "sys_platform != 'win32' and sys_platform != 'cygwin' and platform_python_implementation != 'pypy'",
"version": "==0.13.0"
},
"websockets": {
@ -243,6 +246,7 @@
"sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13",
"sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"
],
"index": "pypi",
"version": "==7.0"
},
"coverage": {

View File

@ -1,3 +1,3 @@
from .main import main
from .main import cli
main()
cli()

View File

@ -2,6 +2,7 @@ import argparse
import logging
from multiprocessing import Process
import click
import sentry_sdk
from apscheduler.util import get_callable_name
@ -12,20 +13,16 @@ from actioner.web import get_server, run_server
logger = logging.getLogger(__name__)
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--once", action="store_true")
return parser.parse_args()
def main():
@click.group()
def cli():
logging.basicConfig(level=LOGGING_LEVEL)
sentry_sdk.init(dsn=SENTRY_DSN)
args = parse_args()
if args.once:
@cli.command()
@click.option('--once', is_flag=True)
def start(once):
if once:
scheduler = create_scheduler()
jobs = {job.func for job in scheduler.get_jobs()}
for job in jobs:
@ -37,4 +34,4 @@ def main():
if __name__ == "__main__":
main()
cli()