add --version option
This commit is contained in:
parent
e89b1d1c89
commit
226456670a
|
@ -0,0 +1 @@
|
||||||
|
__version__ = "v0.0.0"
|
|
@ -1,5 +1,6 @@
|
||||||
# %% imports
|
# %% imports
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
|
@ -8,7 +9,7 @@ import gotify
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import toml
|
import toml
|
||||||
|
|
||||||
__version__ = "v0.0.0"
|
from goat_monitor import __version__
|
||||||
|
|
||||||
|
|
||||||
# %% commands
|
# %% commands
|
||||||
|
@ -26,9 +27,19 @@ __version__ = "v0.0.0"
|
||||||
type=int,
|
type=int,
|
||||||
help="Number of times to try re-running failed command. -1 to retry indefinitely until success",
|
help="Number of times to try re-running failed command. -1 to retry indefinitely until success",
|
||||||
)
|
)
|
||||||
def wrap(command: List[str], config: Path, retries: int):
|
@click.option(
|
||||||
|
"--version",
|
||||||
|
is_flag=True,
|
||||||
|
default=False,
|
||||||
|
help="Print version and exit",
|
||||||
|
)
|
||||||
|
def wrap(command: List[str], config: Path, retries: int, version):
|
||||||
"""Wrap an arbitrary command with gotify notifications"""
|
"""Wrap an arbitrary command with gotify notifications"""
|
||||||
|
|
||||||
|
if version:
|
||||||
|
print(version)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
# read settings first
|
# read settings first
|
||||||
with open(config, "r") as f:
|
with open(config, "r") as f:
|
||||||
settings = toml.load(f)
|
settings = toml.load(f)
|
||||||
|
@ -85,7 +96,7 @@ def wrap(command: List[str], config: Path, retries: int):
|
||||||
with gotify.Gotify(base_url=url, app_token=app_token) as gotify_connection:
|
with gotify.Gotify(base_url=url, app_token=app_token) as gotify_connection:
|
||||||
gotify_connection.create_message(message=message, title=title)
|
gotify_connection.create_message(message=message, title=title)
|
||||||
|
|
||||||
return result.returncode
|
sys.exit(result.returncode)
|
||||||
|
|
||||||
|
|
||||||
# %% main
|
# %% main
|
||||||
|
|
Loading…
Reference in New Issue
Block a user