feat: list command fails when --index is used without --json or --html

This commit is contained in:
Cristian 2020-08-19 13:14:04 -05:00 committed by Cristian Vargas
parent 885ff50449
commit a77d6dc235
2 changed files with 12 additions and 1 deletions

View file

@ -23,7 +23,7 @@ from ..index import (
get_corrupted_folders,
get_unrecognized_folders,
)
from ..logging_util import SmartFormatter, accept_stdin
from ..logging_util import SmartFormatter, accept_stdin, stderr
@docstring(list_all.__doc__)
@ -112,6 +112,13 @@ def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional
command = parser.parse_args(args or ())
filter_patterns_str = accept_stdin(stdin)
if command.index and not (command.json or command.html):
stderr(
'[X] --index can only be used with --json or --html options.\n',
color='red',
)
raise SystemExit(2)
matching_folders = list_all(
filter_patterns_str=filter_patterns_str,
filter_patterns=command.filter_patterns,