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
Markdown
# 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! š¤²**