An open API service indexing awesome lists of open source software.

https://github.com/mo7ammedd/prayercli

C# console app for calculating Islamic prayer times, Qibla direction, and Hijri date with IP geolocation, multiple methods, and styled CLI output.
https://github.com/mo7ammedd/prayercli

cli-app csharp islamic-prayer-times prayer-times

Last synced: 10 months ago
JSON representation

C# console app for calculating Islamic prayer times, Qibla direction, and Hijri date with IP geolocation, multiple methods, and styled CLI output.

Awesome Lists containing this project

README

          

# Prayer CLI

A beautiful, feature-rich console application for Islamic prayer times, Qibla direction, and Hijri dates built with .NET 8.

**Created by [mo7ammedd](https://github.com/Mo7ammedd)**

## Features

- **Accurate Prayer Times**: Uses Adhan.NET library with multiple calculation methods
- **Qibla Direction**: Calculate direction to Kaaba with visual compass
- **Hijri Calendar**: Umm al-Qura calendar support
- **Auto-location**: IP-based geolocation detection
- **Multiple Methods**: Support for various prayer calculation methods
- **Beautiful UI**: Rich console output with Spectre.Console
- **Countdown Timer**: Real-time countdown to next prayer
- **Jumu'ah Reminders**: Special Friday highlights with Khutbah reminders and Surah Al-Kahf suggestions
- **Configuration**: Save and load default settings
- **Cross-platform**: Works on Windows, macOS, and Linux

## Installation

### Prerequisites
- .NET 8.0 SDK or Runtime

### Build from Source
```bash
git clone https://github.com/Mo7ammedd/PrayerCli.git
cd PrayerCli
dotnet restore
dotnet build
dotnet run
```

### Publish Single File
```bash
dotnet publish -c Release -r linux-x64 --self-contained true
```

## Usage

### Basic Commands

#### Get Prayer Times (Default)
```bash
# Use saved defaults or auto-detect location
dotnet run

# Auto-detect location from IP
dotnet run --ip

# Specify coordinates
dotnet run --lat 40.7128 --lon -74.0060 --tz "America/New_York"
```

#### Prayer Command
```bash
# Get prayer times for today
dotnet run prayer

# Get prayer times for specific date
dotnet run prayer --date 2024-01-15

# Use specific calculation method
dotnet run prayer --method UmmAlQura --school Hanafi

# Save current settings as defaults
dotnet run prayer --lat 40.7128 --lon -74.0060 --save-defaults
```

#### Qibla Command
```bash
# Get Qibla direction
dotnet run qibla

# Get Qibla for specific location
dotnet run qibla --lat 40.7128 --lon -74.0060
```

#### Jumu'ah Command
```bash
# Show Jumu'ah (Friday) reminders and information
dotnet run jumuah

# Show Jumu'ah info for specific date
dotnet run jumuah --date 2024-01-19

# Show detailed Surah Al-Kahf information
dotnet run jumuah --show-surah-info

# Use Arabic language
dotnet run jumuah --lang ar
```

### Command Line Options

| Option | Short | Description | Example |
|--------|-------|-------------|---------|
| `--lat` | `-l` | Latitude coordinate (-90 to 90) | `--lat 40.7128` |
| `--lon` | `-o` | Longitude coordinate (-180 to 180) | `--lon -74.0060` |
| `--tz` | `-t` | Timezone | `--tz "America/New_York"` |
| `--ip` | `-i` | Auto-detect location from IP | `--ip` |
| `--method` | `-m` | Calculation method | `--method UmmAlQura` |
| `--school` | `-s` | Islamic school (Shafi/Hanafi) | `--school Hanafi` |
| `--date` | `-d` | Date (YYYY-MM-DD) | `--date 2024-01-15` |
| `--save-defaults` | | Save current settings | `--save-defaults` |
| `--show-surah-info` | | Show Surah Al-Kahf details (Jumu'ah command) | `--show-surah-info` |

### Calculation Methods

- **MWL** - Muslim World League (default)
- **UmmAlQura** - Umm al-Qura University, Makkah
- **Egypt** - Egyptian General Authority of Survey
- **Makkah** - Umm al-Qura University, Makkah
- **Karachi** - University of Islamic Sciences, Karachi
- **ISNA** - Islamic Society of North America
- **Tehran** - Institute of Geophysics, Tehran
- **Jafari** - Shia Ithna Ashari

### Islamic Schools

- **Shafi** - Shafi'i school (default)
- **Hanafi** - Hanafi school

## New Features

- Themes: `--theme` supports `dark`, `light`, `solarized`
- Multi-language: `--lang` supports `en`, `ar`
- Prayer Time History: show ranges with `--days N` starting from `--date`
- Export to Calendar: `--export-ics ` to export selected day as an ICS file

### Examples

```bash
# Themed + Arabic
dotnet run -- prayer --ip --theme solarized --lang ar

# History (7 days from a date)
dotnet run -- prayer --ip --date 2025-09-01 --days 7

# Export ICS for today
dotnet run -- prayer --ip --export-ics today.ics

# Light theme, English, Cairo
dotnet run -- prayer --lat 30.0444 --lon 31.2357 --tz "Africa/Cairo" --theme light --lang en
```

### Extra Options

| Option | Description |
|--------|-------------|
| `--theme` | Visual theme: `dark`, `light`, `solarized` |
| `--lang` | Language: `en`, `ar` |
| `--days` | Number of days to display from `--date` (history/forecast) |
| `--export-ics` | Export selected day to ICS file path |

## Commands

### prayer
```
dotnet run -- prayer [options]
```
Options:
- --ip | --lat --lon --tz
- --method MWL|UmmAlQura|Egypt|Makkah|Karachi|ISNA|Tehran|Jafari
- --school Shafi|Hanafi
- --date YYYY-MM-DD
- --save-defaults
- --theme dark|light|solarized
- --lang en|ar
- --days N (print range from --date)
- --export-ics path.ics (export selected day)

Examples:
```
dotnet run -- prayer --ip --theme solarized --lang ar
dotnet run -- prayer --lat 30.0444 --lon 31.2357 --tz "Africa/Cairo" --date 2025-09-01 --days 7
```

### qibla
```
dotnet run -- qibla [--ip | --lat --lon --tz]
```

### live
```
dotnet run -- live [--ip | --lat --lon --tz] [--theme THEME] [--lang LANG]
```
Continuously updates current time, statuses, and countdown. Ctrl+C to exit.

### week
```
dotnet run -- week [--ip | --lat --lon --tz] [--theme THEME] [--lang LANG] [--start-date YYYY-MM-DD] [--export file]
```
- --export supports .csv or .json

Examples:
```
dotnet run -- week --ip
dotnet run -- week --ip --start-date 2025-09-01 --export week.csv
```

## Project Structure

```
PrayerCli/
├── Commands/ # CLI command handlers
├── Models/ # Data models
├── Services/ # Business logic services
├── Utils/ # Utility functions
├── PrayerCli.csproj # Project file
└── README.md # This file
```

### Key Components

- **`PrayerCommand`**: Main prayer times command handler
- **`QiblaCommand`**: Qibla direction command handler
- **`PrayerCalculationService`**: Prayer time calculations using Adhan.NET
- **`GeolocationService`**: IP-based location detection
- **`QiblaService`**: Qibla direction calculations
- **`ConsoleUtils`**: Beautiful console output formatting

## Configuration

The application automatically creates a configuration file at `~/.prayercli/config.json` when you use the `--save-defaults` flag. This file stores:

- Latitude and longitude coordinates
- Timezone
- Preferred calculation method
- Preferred Islamic school

## Geolocation

The app uses [ip-api.com](http://ip-api.com) for IP-based geolocation. This service provides:

- Accurate coordinates
- City and country information
- Timezone detection

## Dependencies

- **Adhan.NET**: Prayer time calculations
- **Spectre.Console**: Beautiful console output
- **System.CommandLine**: CLI argument parsing
- **System.Text.Json**: JSON configuration handling

## Testing

```bash
dotnet test
```

## Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Author

**mo7ammedd** - [GitHub Profile](https://github.com/Mo7ammedd)

## Acknowledgments

- [Adhan.NET](https://github.com/batoulapps/adhan-dotnet) for prayer time calculations
- [Spectre.Console](https://spectreconsole.net/) for beautiful console output
- [ip-api.com](http://ip-api.com) for geolocation services

## Support

If you encounter any issues or have questions, please:

1. Check the existing issues
2. Create a new issue with detailed information
3. Include your operating system and .NET version

---

## Releases

Prebuilt binaries are published on the GitHub Releases page.

- Latest release: https://github.com/Mo7ammedd/PrayerCli/releases/latest

Download for your OS, then run:

- Linux: `chmod +x PrayerCli && ./PrayerCli`
- macOS: `chmod +x PrayerCli && ./PrayerCli`
- Windows: `PrayerCli.exe`