You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
636 B
23 lines
636 B
import { apiRequest } from '../utils/api.js'; |
|
|
|
/** |
|
* Search repositories |
|
*/ |
|
export async function search(args, server, json) { |
|
const query = args.join(' '); |
|
if (!query) { |
|
console.error('Search query required'); |
|
process.exit(1); |
|
} |
|
const data = await apiRequest(server, `/search?q=${encodeURIComponent(query)}`, 'GET'); |
|
if (json) { |
|
console.log(JSON.stringify(data, null, 2)); |
|
} else { |
|
console.log(`Search results for "${query}":`); |
|
if (Array.isArray(data)) { |
|
data.forEach(repo => { |
|
console.log(` ${repo.npub}/${repo.name} - ${repo.description || 'No description'}`); |
|
}); |
|
} |
|
} |
|
}
|
|
|