UNPKG

aahook

Version:

A CLI tool that displays ASCII art when commands succeed or fail

63 lines • 2.87 kB
"use strict"; 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