UNPKG

hadith-collections

Version:

A comprehensive npm package for searching and browsing hadith collections with Arabic and English support

174 lines (124 loc) • 5.89 kB
# Hadith Collections CLI Tool A single-file command-line interface for navigating hadith collections, books, chapters, and viewing individual hadiths in the terminal. ## Features šŸŒ™ **Hierarchical Navigation**: Collections → Books → Chapters → Hadiths šŸ” **Autocomplete Search**: Type-ahead search for easy navigation šŸ“š **16 Collections**: Including Sahih al-Bukhari, Sahih Muslim, and more 🌐 **Bilingual Support**: Arabic text with English translations when available šŸŽ² **Random Hadith**: Get random hadiths for daily reading ⚔ **Fast Navigation**: Quick back navigation between levels šŸ“œ **Rich Display**: Formatted hadith display with narrator information ## Usage ### Running the CLI ```bash # Run directly node cli.js # Or if installed globally hadith-cli ``` ### Navigation Flow 1. **Select Collection**: Choose from 16 available hadith collections - Use arrow keys or type to search - Collections include: Sahih al-Bukhari, Sahih Muslim, Sunan an-Nasa'i, etc. 2. **Select Book**: Browse books within the selected collection - Each collection has multiple books organized by topic - Example: "Book 1: Revelation", "Book 2: Belief", etc. 3. **Select Chapter**: View chapters within the selected book - Chapters break down books into specific topics - Option to view all hadiths in a book directly 4. **Select Hadith**: Choose individual hadiths to read - Preview shows first 100 characters - Option for random hadith selection 5. **View Hadith**: Full display with: - Arabic text - English translation (when available) - Narrator information - Reference (URN) - Comments and grades (when available) ### Navigation Controls - **Type to search**: Filter options by typing - **Arrow keys**: Navigate through options - **Enter**: Select option - **← Back**: Return to previous level - **Ctrl+C**: Exit the application ### Example Navigation Path ``` Collections ā”œā”€ā”€ Sahih al-Bukhari (صحيح Ų§Ł„ŲØŲ®Ų§Ų±ŁŠ) ā”œā”€ā”€ Book 1: Revelation (كتاب ŲØŲÆŲ” Ų§Ł„ŁˆŲ­Ł‰) ā”œā”€ā”€ Chapter 1: How the Divine Inspiration started... ā”œā”€ā”€ Hadith 1: Narrated 'Umar bin Al-Khattab... ā”œā”€ā”€ Hadith 2: Narrated 'Aisha... └── ... └── ... └── ... ``` ## Available Collections The CLI provides access to these major hadith collections: 1. **Sahih al-Bukhari** (صحيح Ų§Ł„ŲØŲ®Ų§Ų±ŁŠ) - 97 books 2. **Sahih Muslim** (صحيح مسلم) 3. **Sunan an-Nasa'i** (سنن Ų§Ł„Ł†Ų³Ų§Ų¦ŁŠ) 4. **Sunan Abi Dawud** (سنن أبي داود) 5. **Jami` at-Tirmidhi** (Ų¬Ų§Ł…Ų¹ Ų§Ł„ŲŖŲ±Ł…Ų°ŁŠ) 6. **Sunan Ibn Majah** (سنن ابن ماجه) 7. **Muwatta Malik** (Ł…ŁˆŲ·Ų£ Ł…Ų§Ł„Łƒ) 8. **Musnad Ahmad** (مسند Ų£Ų­Ł…ŲÆ) 9. **An-Nawawi's 40 Hadith** (Ų§Ł„Ų£Ų±ŲØŲ¹ŁˆŁ† Ų§Ł„Ł†ŁˆŁˆŁŠŲ©) 10. **Collections of Forty** (Ų§Ł„Ų£Ų±ŲØŲ¹ŁŠŁ†Ų§ŲŖ) 11. **Riyad as-Salihin** (رياض Ų§Ł„ŲµŲ§Ł„Ų­ŁŠŁ†) 12. **Mishkat al-Masabih** (Ł…Ų“ŁƒŲ§Ų© Ų§Ł„Ł…ŲµŲ§ŲØŁŠŲ­) 13. **Al-Adab Al-Mufrad** (الأدب المفرد) 14. **Ash-Shama'il Al-Muhammadiyah** (الؓمائل Ų§Ł„Ł…Ų­Ł…ŲÆŁŠŲ©) 15. **Bulugh al-Maram** (ŲØŁ„ŁˆŲŗ المرام) 16. **Hisn al-Muslim** (حصن المسلم) ## Installation as Global Command To use `hadith-cli` globally: ```bash npm install -g . hadith-cli ``` ## Dependencies - `inquirer-autocomplete-standalone`: For the interactive CLI interface - `sqlite3`: For database access (already included in the main package) ## Technical Details - **Single File**: The entire CLI is contained in `cli.js` - **Database**: Uses the same SQLite database as the main package - **Memory Efficient**: Only loads data as needed for navigation - **Graceful Exit**: Properly closes database connections on exit ## Keyboard Shortcuts - **Ctrl+C**: Exit application gracefully - **Enter**: Confirm selection - **Escape**: Cancel current input - **Tab**: Autocomplete (when applicable) ## Example Session ``` šŸŒ™ Welcome to Hadith Collections CLI ═══════════════════════════════════════ ? šŸ“š Select a hadith collection: Sahih al-Bukhari (صحيح Ų§Ł„ŲØŲ®Ų§Ų±ŁŠ) šŸ“– Books in Sahih al-Bukhari: ────────────────────────────────────── ? šŸ“– Select a book: Book 1: Revelation (كتاب ŲØŲÆŲ” Ų§Ł„ŁˆŲ­Ł‰) šŸ“„ Chapters in Revelation (كتاب ŲØŲÆŲ” Ų§Ł„ŁˆŲ­Ł‰): ────────────────────────────────────── ? šŸ“„ Select a chapter: Chapter 1: How the Divine Inspiration started... šŸ“œ Hadiths in Revelation - How the Divine Inspiration started...: ────────────────────────────────────── ? šŸ“œ Select a hadith to read: Hadith 1: Narrated 'Umar bin Al-Khattab: I heard Allah's Messenger saying... šŸ•Œ HADITH DISPLAY ══════════════════════════════════════════════════════════ šŸ“ URN: 1:1:1:1 šŸ“Š Collection ID: 1, Book ID: 1 šŸ‘¤ حدثنا šŸ“œ Arabic Content: ──────────────────────── [Arabic hadith text] šŸ‘¤ رضي الله عنه šŸŒ English Translation: ──────────────────────── Narrated 'Umar bin Al-Khattab: I heard Allah's Messenger saying, "The reward of deeds depends upon the intentions..." šŸ“– Reference: Book 1, Hadith 1 ══════════════════════════════════════════════════════════ Press Enter to continue... ``` --- **May Allah bless your study of the Sunnah! 🤲**