Skip to content

Commit

Permalink
feat: add URL support to CLI (#99)
Browse files Browse the repository at this point in the history
Signed-off-by: Panos Vagenas <[email protected]>
  • Loading branch information
vagenas authored Sep 24, 2024
1 parent c65a01c commit 3c46e42
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docling/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import Annotated, Iterable, List, Optional

import typer
from docling_core.utils.file import resolve_file_source
from pydantic import AnyUrl

from docling.backend.docling_parse_backend import DoclingParseDocumentBackend
Expand Down Expand Up @@ -109,11 +110,11 @@ def export_documents(
@app.command(no_args_is_help=True)
def convert(
input_sources: Annotated[
List[Path],
List[str],
typer.Argument(
...,
metavar="source",
help="PDF files to convert. Directories are also accepted.",
help="PDF files to convert. Can be local file / directory paths or URL.",
),
],
export_json: Annotated[
Expand Down Expand Up @@ -167,7 +168,8 @@ def convert(
logging.basicConfig(level=logging.INFO)

input_doc_paths: List[Path] = []
for source in input_sources:
for src in input_sources:
source = resolve_file_source(source=src)
if not source.exists():
err_console.print(
f"[red]Error: The input file {source} does not exist.[/red]"
Expand Down

0 comments on commit 3c46e42

Please sign in to comment.