summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOhad Eytan <ohadey@gmail.com>2021-05-14 11:26:04 +0300
committerGitHub <noreply@github.com>2021-05-14 11:26:04 +0300
commit28d118155e6361133717a20822e5c710edc6c973 (patch)
treeddfd4de5a73b9f28394d0d9fd291781a1e9123aa
parent5e394ad7a66f2afd9d79921424b8f76534f5b4d6 (diff)
Add quiet flag (#5)
-rw-r--r--README.md1
-rw-r--r--alarmpy.py14
2 files changed, 10 insertions, 5 deletions
diff --git a/README.md b/README.md
index 5ffbb7c..772f9bd 100644
--- a/README.md
+++ b/README.md
@@ -30,6 +30,7 @@ Options:
--routine-delay INTEGER Routine message delay in seconds
--alarm-id Print alarm ID
--repeat-alarms Do not suppress ongoing alarms
+ --quiet Print only active alarms
--help Show this message and exit.
```
diff --git a/alarmpy.py b/alarmpy.py
index 497eabd..d3ee0f1 100644
--- a/alarmpy.py
+++ b/alarmpy.py
@@ -16,12 +16,13 @@ class Alarm(object):
}
def __init__(
- self, delay=1, routine_delay=60 * 5, alarm_id=False, repeat_alarms=False
+ self, delay=1, routine_delay=60 * 5, alarm_id=False, repeat_alarms=False, quiet=False
):
self.delay = delay
self.last_routine_delay = routine_delay
self.alarm_id = alarm_id
self.repeat_alarms = repeat_alarms
+ self.quiet = quiet
self.current_alarms = []
self.last_routine_output = 0
@@ -83,12 +84,14 @@ class Alarm(object):
click.secho(f"{ts} ", nl=False)
def output_error(self, err):
- self.output_leading_timestamp()
- click.secho(err, fg="yellow", bold=True)
+ if not self.quiet:
+ self.output_leading_timestamp()
+ click.secho(err, fg="yellow", bold=True)
def output_routine(self):
- self.output_leading_timestamp()
- click.secho("No active alarms", fg="green")
+ if not self.quiet:
+ self.output_leading_timestamp()
+ click.secho(f"No active alarms", fg="green")
def output_alarms(self, cities, alarm_id):
self.output_leading_timestamp()
@@ -105,6 +108,7 @@ class Alarm(object):
)
@click.option("--alarm-id", is_flag=True, help="Print alarm IDs")
@click.option("--repeat-alarms", is_flag=True, help="Do not suppress ongoing alarms")
+@click.option("--quiet", is_flag=True, help="Print only active alarms")
def alarm(**kwargs):
Alarm(**kwargs).start()