feat: update usage instructions and improve input/output handling in CLI
This commit is contained in:
@@ -30,7 +30,7 @@ bun test src/supplier/supplier-scoring.test.ts
|
|||||||
./node_modules/.bin/tsc --noEmit
|
./node_modules/.bin/tsc --noEmit
|
||||||
|
|
||||||
# ASIN lead-list pipeline (LLM-based)
|
# ASIN lead-list pipeline (LLM-based)
|
||||||
bun run src/index.ts input/leads.xlsx --out output/results.xlsx
|
bun start leads.xlsx --out results.xlsx
|
||||||
|
|
||||||
# Supplier UPC pipeline (deterministic)
|
# Supplier UPC pipeline (deterministic)
|
||||||
bun run upc-file --input input/supplier.xlsx --out output/supplier_ranked.xlsx
|
bun run upc-file --input input/supplier.xlsx --out output/supplier_ranked.xlsx
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -21,17 +21,19 @@ cp .env.example .env
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bun run src/index.ts input/<input.csv|xlsx> [--out output/results.xlsx]
|
bun start <input.csv|xlsx> [--out results.xlsx]
|
||||||
```
|
```
|
||||||
|
|
||||||
Add `--claude` to use Anthropic Claude instead of local LM Studio for LLM analysis.
|
Add `--claude` to use Anthropic Claude instead of local LM Studio for LLM analysis.
|
||||||
|
Bare input and output filenames use the `input/` and `output/` directories. Pass a path containing a directory to override those defaults.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bun run src/index.ts input/leads.xlsx
|
bun start leads.xlsx
|
||||||
bun run src/index.ts input/leads.csv --out output/results.xlsx
|
bun start leads.csv --out results.xlsx
|
||||||
bun run src/index.ts input/leads.xlsx --claude
|
bun start leads.xlsx --claude
|
||||||
|
bun start archive/leads.xlsx --out exports/results.xlsx
|
||||||
```
|
```
|
||||||
|
|
||||||
Large-file behavior:
|
Large-file behavior:
|
||||||
|
|||||||
33
src/index.ts
33
src/index.ts
@@ -14,6 +14,8 @@ import path from "node:path";
|
|||||||
import type { AnalysisResult } from "./types.ts";
|
import type { AnalysisResult } from "./types.ts";
|
||||||
|
|
||||||
const INPUT_BATCH_SIZE = 50;
|
const INPUT_BATCH_SIZE = 50;
|
||||||
|
const INPUT_DIR = "input";
|
||||||
|
const OUTPUT_DIR = "output";
|
||||||
|
|
||||||
function parseSellabilityArg(args: string[]): SellabilityFilter {
|
function parseSellabilityArg(args: string[]): SellabilityFilter {
|
||||||
const sellabilityArg = args.find((a) => a.startsWith("--sellability="));
|
const sellabilityArg = args.find((a) => a.startsWith("--sellability="));
|
||||||
@@ -45,7 +47,7 @@ function parseArgs(): {
|
|||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
const outputFile = readFlagValue(args, "--out", "--output");
|
const outputFile = readFlagValue(args, "--out", "--output");
|
||||||
const useClaude = args.includes("--claude");
|
const useClaude = args.includes("--claude");
|
||||||
const inputFile = readInputFileArg(
|
const inputFileArg = readInputFileArg(
|
||||||
args,
|
args,
|
||||||
"--out",
|
"--out",
|
||||||
"--output",
|
"--output",
|
||||||
@@ -53,14 +55,19 @@ function parseArgs(): {
|
|||||||
);
|
);
|
||||||
const sellability = parseSellabilityArg(args);
|
const sellability = parseSellabilityArg(args);
|
||||||
|
|
||||||
if (!inputFile) {
|
if (!inputFileArg) {
|
||||||
console.error(
|
console.error(
|
||||||
"Usage: bun run src/index.ts <input.csv|xlsx> [--out results.xlsx|--output results.xlsx] [--sellability available|all] [--claude]",
|
"Usage: bun run src/index.ts <input.csv|xlsx> [--out results.xlsx|--output results.xlsx] [--sellability available|all] [--claude]\nBare filenames are read from input/ and written to output/.",
|
||||||
);
|
);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return { inputFile, outputFile, sellability, useClaude };
|
return {
|
||||||
|
inputFile: resolveInputPath(inputFileArg),
|
||||||
|
outputFile,
|
||||||
|
sellability,
|
||||||
|
useClaude,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function readFlagValue(args: string[], ...flags: string[]): string | undefined {
|
function readFlagValue(args: string[], ...flags: string[]): string | undefined {
|
||||||
@@ -101,11 +108,25 @@ function readInputFileArg(
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isBareFilename(filePath: string): boolean {
|
||||||
|
return !path.isAbsolute(filePath) && !/[\\/]/.test(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveInputPath(inputFile: string): string {
|
||||||
|
return isBareFilename(inputFile)
|
||||||
|
? path.join(INPUT_DIR, inputFile)
|
||||||
|
: inputFile;
|
||||||
|
}
|
||||||
|
|
||||||
function resolveBaseOutputPath(inputFile: string, outputFile?: string): string {
|
function resolveBaseOutputPath(inputFile: string, outputFile?: string): string {
|
||||||
if (outputFile) return outputFile;
|
if (outputFile) {
|
||||||
|
return isBareFilename(outputFile)
|
||||||
|
? path.join(OUTPUT_DIR, outputFile)
|
||||||
|
: outputFile;
|
||||||
|
}
|
||||||
|
|
||||||
const parsedInput = path.parse(inputFile);
|
const parsedInput = path.parse(inputFile);
|
||||||
return path.join("output", `${parsedInput.name}_results.xlsx`);
|
return path.join(OUTPUT_DIR, `${parsedInput.name}_results.xlsx`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
|||||||
Reference in New Issue
Block a user