mirror of
https://github.com/ArchiveBox/ArchiveBox
synced 2024-11-10 06:34:16 +00:00
feat: list command fails when --index is used without --json or --html
This commit is contained in:
parent
885ff50449
commit
a77d6dc235
2 changed files with 12 additions and 1 deletions
|
@ -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,
|
||||
|
|
|
@ -32,3 +32,7 @@ def test_list_html_index(process, disable_extractors_dict):
|
|||
output_html = list_process.stdout.decode("utf-8")
|
||||
assert "<footer>" in output_html
|
||||
assert "http://127.0.0.1:8080/static/example.com.html" in output_html
|
||||
|
||||
def test_list_index_with_wrong_flags(process):
|
||||
list_process = subprocess.run(["archivebox", "list", "--index"], capture_output=True)
|
||||
assert "--index can only be used with --json or --html options." in list_process.stderr.decode("utf-8")
|
Loading…
Reference in a new issue