Skip to content

Commit 7221920

Browse files
authored
✨ allow passing URLs to CLI tool (#453)
1 parent d49ce59 commit 7221920

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/v2/cli.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Command, OptionValues } from "commander";
2-
import { Client } from "./client.js";
3-
import { PathInput } from "../input/index.js";
42
import * as console from "console";
3+
import { Client, InputSource, PathInput, UrlInput } from "@/index.js";
54
import { BaseInference } from "@/v2/parsing/inference/index.js";
65
import { BaseProduct } from "@/v2/product/baseProduct.js";
76
import {
@@ -37,7 +36,12 @@ async function enqueueAndGetInference(
3736
options: OptionValues
3837
): Promise<void> {
3938
const mindeeClient = initClient(options);
40-
const inputSource = new PathInput({ inputPath: inputPath });
39+
let inputSource: InputSource;
40+
if (inputPath.startsWith("https://")) {
41+
inputSource = new UrlInput({ url: inputPath });
42+
} else {
43+
inputSource = new PathInput({ inputPath: inputPath });
44+
}
4145
const response = await mindeeClient.enqueueAndGetResult(
4246
product,
4347
inputSource,
@@ -71,7 +75,7 @@ function addMainOptions(prog: Command) {
7175
"-m, --model <model_id>",
7276
"Model ID (required)"
7377
);
74-
prog.argument("<input_path>", "full path to the file");
78+
prog.argument("<input_path>", "full path or URL to the file");
7579
}
7680

7781
export function cli() {

tests/test_v1_code_samples.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ OUTPUT_FILE='../test_code_samples/_test_v1.js'
55
ACCOUNT=$1
66
ENDPOINT=$2
77

8+
if [ -z "${ACCOUNT}" ]; then echo "ACCOUNT is required"; exit 1; fi
9+
if [ -z "${ENDPOINT}" ]; then echo "ENDPOINT is required"; exit 1; fi
10+
811
rm -fr ../test_code_samples
912
mkdir ../test_code_samples
1013

tests/test_v2_code_samples.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ do
3232
sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_CROP_MODEL_ID}/" $OUTPUT_FILE
3333
fi
3434

35-
if echo "${f}" | grep -q "v2_extraction.txt"
35+
if echo "${f}" | grep -q "v2_extraction"
3636
then
3737
sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID}/" $OUTPUT_FILE
3838
fi

0 commit comments

Comments
 (0)