@ia-qa/cli 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +47 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* them on the hosted server (https://www.ia-qa.com). 148 QA/LLM/dev tools, no signup, no key.
|
|
10
10
|
*
|
|
11
11
|
* ia-qa <tool> [input] [--flag value] [--json] [--out <file>] [--stdin]
|
|
12
|
+
* ia-qa <tool> --<param>-file <path> # read a param from a file (multiline-safe)
|
|
12
13
|
* ia-qa list [--category <c>]
|
|
13
14
|
* ia-qa <tool> --help
|
|
14
15
|
* ia-qa --help
|
|
@@ -40,7 +41,15 @@ function parseArgv(argv) {
|
|
|
40
41
|
for (let i = 0; i < argv.length; i++) {
|
|
41
42
|
const tok = argv[i];
|
|
42
43
|
if (tok.startsWith('--')) {
|
|
43
|
-
const
|
|
44
|
+
const bodyTok = tok.slice(2);
|
|
45
|
+
const eq = bodyTok.indexOf('=');
|
|
46
|
+
if (eq !== -1) {
|
|
47
|
+
const key = bodyTok.slice(0, eq);
|
|
48
|
+
const val = bodyTok.slice(eq + 1);
|
|
49
|
+
flags[key] = flags[key] === undefined ? val : [].concat(flags[key], val);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const key = bodyTok;
|
|
44
53
|
const next = argv[i + 1];
|
|
45
54
|
if (next === undefined || next.startsWith('--')) {
|
|
46
55
|
flags[key] = flags[key] === undefined ? true : flags[key];
|
|
@@ -221,10 +230,36 @@ function toolHelp(tool) {
|
|
|
221
230
|
}
|
|
222
231
|
}
|
|
223
232
|
if (primary) lines.push('', `Primary input "${primary}" can be given positionally or via --stdin.`);
|
|
233
|
+
lines.push('', 'Any --<param> also accepts --<param>-file <path> (multiline-safe, e.g. --inputs-file fields.txt).');
|
|
224
234
|
lines.push('', 'Common: --json --out <file> --stdin --server <url>');
|
|
225
235
|
return lines.join('\n');
|
|
226
236
|
}
|
|
227
237
|
|
|
238
|
+
// ── file-backed params (--<param>-file) ─────────────────────────────────────
|
|
239
|
+
// Read a param's value from a file instead of argv. This sidesteps shells that
|
|
240
|
+
// mangle argv: on Windows, `npx` re-spawns the resolved binary through a cmd.exe
|
|
241
|
+
// hop that truncates any argument at its first newline, so a multiline value
|
|
242
|
+
// (e.g. --inputs with one field per line) silently loses everything after line 1.
|
|
243
|
+
// A file never transits argv, so it survives regardless of the invoker.
|
|
244
|
+
function readFileParams(props, flags, readFile = (p) => fs.readFileSync(p, 'utf8')) {
|
|
245
|
+
const out = {};
|
|
246
|
+
for (const k of Object.keys(props)) {
|
|
247
|
+
const fk = `${k}-file`;
|
|
248
|
+
if (flags[fk] === undefined) continue;
|
|
249
|
+
if (typeof flags[fk] !== 'string') {
|
|
250
|
+
throw new CliError(`--${fk} needs a single file path, e.g. --${fk} ${k}.txt`, 2);
|
|
251
|
+
}
|
|
252
|
+
if (flags[k] !== undefined) {
|
|
253
|
+
throw new CliError(`Pass either --${k} or --${fk}, not both.`, 2);
|
|
254
|
+
}
|
|
255
|
+
let raw;
|
|
256
|
+
try { raw = readFile(path.resolve(flags[fk])); }
|
|
257
|
+
catch (e) { throw new CliError(`Cannot read --${fk} "${flags[fk]}": ${e.message}`, 2); }
|
|
258
|
+
out[k] = coerce(props[k], raw.replace(/\r?\n$/, ''));
|
|
259
|
+
}
|
|
260
|
+
return out;
|
|
261
|
+
}
|
|
262
|
+
|
|
228
263
|
// ── main ─────────────────────────────────────────────────────────────────────
|
|
229
264
|
|
|
230
265
|
async function main(argv) {
|
|
@@ -261,6 +296,7 @@ async function main(argv) {
|
|
|
261
296
|
for (const [k, prop] of Object.entries(props)) {
|
|
262
297
|
if (flags[k] !== undefined) params[k] = coerce(prop, flags[k]);
|
|
263
298
|
}
|
|
299
|
+
Object.assign(params, readFileParams(props, flags));
|
|
264
300
|
const primary = primaryParam(schema);
|
|
265
301
|
if (primary) {
|
|
266
302
|
if (flags.stdin || positional[0] === '-') params[primary] = fs.readFileSync(0, 'utf8').replace(/\n$/, '');
|
|
@@ -278,8 +314,16 @@ async function main(argv) {
|
|
|
278
314
|
process.stderr.write(`⚠ Sending secret param(s) [${secretKeys.join(', ')}] to ${server} — make sure you trust this server (set via --server/$IAQA_SERVER).\n`);
|
|
279
315
|
}
|
|
280
316
|
|
|
317
|
+
let outPath = null;
|
|
318
|
+
if (flags.out !== undefined) {
|
|
319
|
+
if (typeof flags.out !== 'string') {
|
|
320
|
+
throw new CliError('--out needs a single file path, e.g. --out result.json', 2);
|
|
321
|
+
}
|
|
322
|
+
outPath = flags.out;
|
|
323
|
+
}
|
|
324
|
+
|
|
281
325
|
const data = await callTool(server, tool.name, params);
|
|
282
|
-
process.stdout.write(emit(data, { json: !!flags.json, out:
|
|
326
|
+
process.stdout.write(emit(data, { json: !!flags.json, out: outPath, toolName: tool.name }) + '\n');
|
|
283
327
|
}
|
|
284
328
|
|
|
285
329
|
if (require.main === module) {
|
|
@@ -289,4 +333,4 @@ if (require.main === module) {
|
|
|
289
333
|
});
|
|
290
334
|
}
|
|
291
335
|
|
|
292
|
-
module.exports = { main, parseArgv, coerce, parseBool, primaryParam, emit, isLarge, compactHelp, listTools, toolHelp };
|
|
336
|
+
module.exports = { main, parseArgv, coerce, parseBool, primaryParam, readFileParams, emit, isLarge, compactHelp, listTools, toolHelp };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ia-qa/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Run ia-qa.com's 148 QA/LLM/dev tools from your shell — for AI agents (Claude Code, Copilot CLI) and humans. Zero dependencies, no signup; most tools key-free, BYOK for the LLM-powered ones.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ia-qa",
|