fix clearing and listing
This commit is contained in:
@@ -97,7 +97,7 @@ documentation for details.''')
|
||||
not specified''')
|
||||
|
||||
args = parser.parse_args()
|
||||
if not args.cmd:
|
||||
if 'cmd' not in args:
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
return args
|
||||
@@ -126,13 +126,14 @@ def cli():
|
||||
|
||||
def cli_list(args, db):
|
||||
for service, failures in sysalert.db.get_services(db).items():
|
||||
if args.service and args.service == service:
|
||||
if not args.service or (args.service and args.service == service):
|
||||
print(f'{service}: {failures} failures')
|
||||
return 0
|
||||
|
||||
def cli_clear(args, db):
|
||||
if not args.service and not args.force:
|
||||
print(f'No service specified, use "--force" to clear all services', sys.stderr)
|
||||
print(f'No service specified, use "--force" to clear all services',
|
||||
file=sys.stderr)
|
||||
return 1
|
||||
if args.service:
|
||||
sysalert.db.clear_failure(args.service, db)
|
||||
|
||||
Reference in New Issue
Block a user