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
|
||||
|
||||
# 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)
|
||||
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
|
||||
|
||||
```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.
|
||||
Bare input and output filenames use the `input/` and `output/` directories. Pass a path containing a directory to override those defaults.
|
||||
|
||||
Examples:
|
||||
|
||||
```bash
|
||||
bun run src/index.ts input/leads.xlsx
|
||||
bun run src/index.ts input/leads.csv --out output/results.xlsx
|
||||
bun run src/index.ts input/leads.xlsx --claude
|
||||
bun start leads.xlsx
|
||||
bun start leads.csv --out results.xlsx
|
||||
bun start leads.xlsx --claude
|
||||
bun start archive/leads.xlsx --out exports/results.xlsx
|
||||
```
|
||||
|
||||
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";
|
||||
|
||||
const INPUT_BATCH_SIZE = 50;
|
||||
const INPUT_DIR = "input";
|
||||
const OUTPUT_DIR = "output";
|
||||
|
||||
function parseSellabilityArg(args: string[]): SellabilityFilter {
|
||||
const sellabilityArg = args.find((a) => a.startsWith("--sellability="));
|
||||
@@ -45,7 +47,7 @@ function parseArgs(): {
|
||||
const args = process.argv.slice(2);
|
||||
const outputFile = readFlagValue(args, "--out", "--output");
|
||||
const useClaude = args.includes("--claude");
|
||||
const inputFile = readInputFileArg(
|
||||
const inputFileArg = readInputFileArg(
|
||||
args,
|
||||
"--out",
|
||||
"--output",
|
||||
@@ -53,14 +55,19 @@ function parseArgs(): {
|
||||
);
|
||||
const sellability = parseSellabilityArg(args);
|
||||
|
||||
if (!inputFile) {
|
||||
if (!inputFileArg) {
|
||||
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);
|
||||
}
|
||||
|
||||
return { inputFile, outputFile, sellability, useClaude };
|
||||
return {
|
||||
inputFile: resolveInputPath(inputFileArg),
|
||||
outputFile,
|
||||
sellability,
|
||||
useClaude,
|
||||
};
|
||||
}
|
||||
|
||||
function readFlagValue(args: string[], ...flags: string[]): string | undefined {
|
||||
@@ -101,11 +108,25 @@ function readInputFileArg(
|
||||
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 {
|
||||
if (outputFile) return outputFile;
|
||||
if (outputFile) {
|
||||
return isBareFilename(outputFile)
|
||||
? path.join(OUTPUT_DIR, outputFile)
|
||||
: outputFile;
|
||||
}
|
||||
|
||||
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() {
|
||||
|
||||
Reference in New Issue
Block a user