aahook
Version:
A CLI tool that displays ASCII art when commands succeed or fail
63 lines ⢠2.87 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.browseCommand = browseCommand;
const github_fetcher_1 = require("../github-fetcher");
/**
* Browse available ASCII arts in repository
*/
async function browseCommand(options = {}) {
const fetcher = new github_fetcher_1.GitHubFetcher();
try {
console.log('\nš Fetching available ASCII arts from repository...');
// Clear cache if requested
if (options.cache === false) {
await fetcher.clearCache();
console.log('šļø Cache cleared');
}
// Fetch index
const index = await fetcher.fetchIndex();
console.log('\nšØ === Available ASCII Arts ===\n');
console.log(`š Total: ${index.total} arts in ${index.categories.length} categories`);
console.log(`š
Updated: ${new Date(index.updated).toLocaleDateString()}\n`);
// Display categories
for (const category of index.categories) {
console.log(`š ${category.displayName}`);
console.log(` Category: ${category.name}`);
console.log(` Arts: ${category.count}`);
// Fetch and display arts in this category
try {
const categoryMeta = await fetcher.fetchCategory(category.name);
if (categoryMeta.arts && categoryMeta.arts.length > 0) {
console.log(' Available arts:');
for (const art of categoryMeta.arts) {
console.log(` ⢠${art.name} - ${art.description}`);
if (art.tags.length > 0) {
console.log(` Tags: ${art.tags.join(', ')}`);
}
}
}
}
catch {
// If META.json doesn't exist, just show count
console.log(` (${category.count} arts available)`);
}
console.log();
}
// Show installation instructions
console.log('ā'.repeat(50));
console.log('\nš” How to use:');
console.log(' Preview: npx aahook preview <category>/<name> --remote');
console.log(' Install: npx aahook install <category>/<name>');
console.log(' Example: npx aahook install animals/cat\n');
// Show contribution instructions
console.log('š¤ Want to contribute your ASCII art?');
console.log(' Submit a PR to: https://github.com/MidoriTakahashi77/aahook');
console.log(' Add your art in: arts/<category>/<name>.txt\n');
}
catch (error) {
console.error(`\nā Failed to browse repository: ${error.message}`);
console.error('š” Check your internet connection and try again.\n');
process.exit(1);
}
}
//# sourceMappingURL=browse.js.map
;