From d04348512b1fa364b82f1fde691e556efc0c19dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Wed, 4 Mar 2026 10:50:02 +0100 Subject: [PATCH] :sparkles: allow passing URLs to CLI tool --- src/v2/cli.ts | 12 ++++++++---- tests/test_v1_code_samples.sh | 3 +++ tests/test_v2_code_samples.sh | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/v2/cli.ts b/src/v2/cli.ts index 22e69f8c..8135f2d7 100644 --- a/src/v2/cli.ts +++ b/src/v2/cli.ts @@ -1,7 +1,6 @@ import { Command, OptionValues } from "commander"; -import { Client } from "./client.js"; -import { PathInput } from "../input/index.js"; import * as console from "console"; +import { Client, InputSource, PathInput, UrlInput } from "@/index.js"; import { BaseInference } from "@/v2/parsing/inference/index.js"; import { BaseProduct } from "@/v2/product/baseProduct.js"; import { @@ -37,7 +36,12 @@ async function enqueueAndGetInference( options: OptionValues ): Promise { const mindeeClient = initClient(options); - const inputSource = new PathInput({ inputPath: inputPath }); + let inputSource: InputSource; + if (inputPath.startsWith("https://")) { + inputSource = new UrlInput({ url: inputPath }); + } else { + inputSource = new PathInput({ inputPath: inputPath }); + } const response = await mindeeClient.enqueueAndGetResult( product, inputSource, @@ -71,7 +75,7 @@ function addMainOptions(prog: Command) { "-m, --model ", "Model ID (required)" ); - prog.argument("", "full path to the file"); + prog.argument("", "full path or URL to the file"); } export function cli() { diff --git a/tests/test_v1_code_samples.sh b/tests/test_v1_code_samples.sh index 94448970..8f4412c8 100755 --- a/tests/test_v1_code_samples.sh +++ b/tests/test_v1_code_samples.sh @@ -5,6 +5,9 @@ OUTPUT_FILE='../test_code_samples/_test_v1.js' ACCOUNT=$1 ENDPOINT=$2 +if [ -z "${ACCOUNT}" ]; then echo "ACCOUNT is required"; exit 1; fi +if [ -z "${ENDPOINT}" ]; then echo "ENDPOINT is required"; exit 1; fi + rm -fr ../test_code_samples mkdir ../test_code_samples diff --git a/tests/test_v2_code_samples.sh b/tests/test_v2_code_samples.sh index 4e74e258..4cbda82c 100755 --- a/tests/test_v2_code_samples.sh +++ b/tests/test_v2_code_samples.sh @@ -32,7 +32,7 @@ do sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_CROP_MODEL_ID}/" $OUTPUT_FILE fi - if echo "${f}" | grep -q "v2_extraction.txt" + if echo "${f}" | grep -q "v2_extraction" then sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID}/" $OUTPUT_FILE fi