Initial commit with translated description

This commit is contained in:
2026-03-29 10:22:43 +08:00
commit fe7efbf39e
17 changed files with 609 additions and 0 deletions

34
scripts/search_stocks.js Normal file
View File

@@ -0,0 +1,34 @@
#!/usr/bin/env node
const apiClient = require('./api_client');
async function searchStocks(query, limit = 10) {
return apiClient.get('/stock/search', { query, limit: String(limit) });
}
async function main() {
const args = process.argv.slice(2);
if (args.length === 0) {
console.log(JSON.stringify({
usage: 'node scripts/search_stocks.js <query> [--limit=10]',
example: 'node scripts/search_stocks.js apple --limit=5',
}, null, 2));
process.exit(1);
}
let limit = 10;
const queryParts = [];
for (const arg of args) {
if (arg.startsWith('--limit=')) {
const val = parseInt(arg.split('=')[1], 10);
if (!isNaN(val)) limit = val;
} else {
queryParts.push(arg);
}
}
const result = await searchStocks(queryParts.join(' '), limit);
console.log(JSON.stringify(result, null, 2));
}
main();