Skip to content

Commit 0d19db8

Browse files
committed
cli errors leverage click output and suggest --help
1 parent 1a2eecc commit 0d19db8

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

apprise/cli.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,27 +468,30 @@ def main(ctx, body, title, config, attach, urls, notification_type, theme, tag,
468468
# Simple Error Checking
469469
notification_type = notification_type.strip().lower()
470470
if notification_type not in NOTIFY_TYPES:
471-
logger.error(
471+
click.echo(
472472
'The --notification-type (-n) value of {} is not supported.'
473473
.format(notification_type))
474+
click.echo("Try 'apprise --help' for more information.")
474475
# 2 is the same exit code returned by Click if there is a parameter
475476
# issue. For consistency, we also return a 2
476477
ctx.exit(2)
477478

478479
input_format = input_format.strip().lower()
479480
if input_format not in NOTIFY_FORMATS:
480-
logger.error(
481+
click.echo(
481482
'The --input-format (-i) value of {} is not supported.'
482483
.format(input_format))
484+
click.echo("Try 'apprise --help' for more information.")
483485
# 2 is the same exit code returned by Click if there is a parameter
484486
# issue. For consistency, we also return a 2
485487
ctx.exit(2)
486488

487489
storage_mode = storage_mode.strip().lower()
488490
if storage_mode not in PERSISTENT_STORE_MODES:
489-
logger.error(
491+
click.echo(
490492
'The --storage-mode (-SM) value of {} is not supported.'
491493
.format(storage_mode))
494+
click.echo("Try 'apprise --help' for more information.")
492495
# 2 is the same exit code returned by Click if there is a parameter
493496
# issue. For consistency, we also return a 2
494497
ctx.exit(2)
@@ -500,9 +503,10 @@ def main(ctx, body, title, config, attach, urls, notification_type, theme, tag,
500503
if exists(path_decode(path))]
501504

502505
if storage_uid_length < 2:
503-
logger.error(
506+
click.echo(
504507
'The --storage-uid-length (-SUL) value can not be lower '
505508
'then two (2).')
509+
click.echo("Try 'apprise --help' for more information.")
506510

507511
# 2 is the same exit code returned by Click if there is a
508512
# parameter issue. For consistency, we also return a 2
@@ -683,9 +687,10 @@ def main(ctx, body, title, config, attach, urls, notification_type, theme, tag,
683687
asset=asset, recursion=recursion_depth))
684688

685689
if not dry_run and not (a or storage_action):
686-
logger.error(
690+
click.echo(
687691
'You must specify at least one server URL or populated '
688692
'configuration file.')
693+
click.echo("Try 'apprise --help' for more information.")
689694
ctx.exit(1)
690695

691696
# each --tag entry comprises of a comma separated 'and' list
@@ -700,9 +705,10 @@ def main(ctx, body, title, config, attach, urls, notification_type, theme, tag,
700705
# - urls are now to be interpreted as best matching namespaces
701706
#
702707
if storage_prune_days < 0:
703-
logger.error(
708+
click.echo(
704709
'The --storage-prune-days (-SPD) value can not be lower '
705710
'then zero (0).')
711+
click.echo("Try 'apprise --help' for more information.")
706712

707713
# 2 is the same exit code returned by Click if there is a
708714
# parameter issue. For consistency, we also return a 2

0 commit comments

Comments
 (0)