Skip to content

Commit

Permalink
small fixes for running using make
Browse files Browse the repository at this point in the history
  • Loading branch information
renatoaraujo committed Mar 24, 2024
1 parent 307c3cd commit 1ecb553
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 48 deletions.
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
.PHONY: build letter
.PHONY: build letter test

# Run tests
test:
./gradlew test

# Build the project
build:
./gradlew build

# Generate the invitation letter PDF
letter: build
./gradlew run -PconfigPath=$(firstword $(filter-out $@,$(MAKECMDGOALS))) -PoutputPath=$(word 2, $(filter-out $@,$(MAKECMDGOALS)))

%:
@:
if [ -z "$(CONFIG_PATH)" ] || [ -z "$(OUTPUT_PATH)" ]; then \
echo "Usage: make letter CONFIG_PATH=your-config.json OUTPUT_PATH=output/invitation-letter.pdf"; \
else \
./gradlew run --args="-c '$(CONFIG_PATH)' -o '$(OUTPUT_PATH)'"; \
fi
94 changes: 51 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,83 @@
UK Invitation Letter Generator
===
# UK Invitation Letter Generator

This is a Kotlin-based application designed to generate invitation letters for visitors to the UK.
It reads a JSON configuration file to gather details about the host, guests, and other relevant information.
It then generates an invitation letter in PDF format based on these details.
This Kotlin application simplifies the process of creating invitation letters for UK visitors. It utilizes a JSON configuration file to compile necessary details about the host, guests, and visit specifics, producing a formal invitation letter in PDF format.

## Motivation
## Why This Project Exists

In recent years, I found myself writing more invitation letters for friends and family visiting me in the UK than
actual lines of code. While crafting these letters is tied to the exciting prospect of welcoming a loved one, it's a
tedious task, especially when the original template goes missing.
Creating personalized invitation letters for visiting friends and family can be time-consuming. This project was born from a personal need to streamline the process, combining a practical solution with an opportunity to refine my Kotlin skills.

So, I decided to create this small service both as a way to practice Kotlin and to streamline the invitation letter
generation for my future guests.
## Key Features

## Features
- Parses host, guest, and visitation details from a specified JSON file.
- Crafts a personalized invitation letter from the parsed details.
- Outputs the letter as a PDF file, ready for printing or emailing.
- See the [example section below](#example-of-generated-pdf-image) for a visual preview.

- Reads host, guest, and visit details from a JSON configuration file.
- Generates a formal invitation letter based on the provided details.
- Outputs the generated letter as a PDF file.
- Check the [example below](#example-of-generated-pdf-image)
## Getting Started

## Requirements
- JDK 8 or higher
- Gradle
- Make (optional, for simplified command execution)
### Prerequisites

## Usage
### Configuration
Refer to the provided `config.sample.json` for an overview of the configuration options.
- Java Development Kit (JDK) version 8 or newer.
- Gradle for building and running the application.
- Make (optional) simplifies the execution process through predefined commands.

### Setup and Execution

#### Configuring Your Invitation

Start by modifying `config.sample.json` to include your specific invitation details.

#### Building the Project

To compile the project, run:

### Using Make for Simplified Execution (recommended)
With the provided `Makefile`, you can easily build and generate the letter using:
```bash
make letter /path/to/my-custom-config.json /path/to/invitation-letter.pdf
./gradlew build
```

### Using Gradle
Build the with Gradle
#### Generating Your Letter

**Using Make (Recommended):**

```bash
./gradlew build
make letter CONFIG_PATH=/path/to/your-config.json OUTPUT_PATH=/path/to/output/invitation-letter.pdf
```
Run the application using the following command:

**Using Gradle:**

To execute the application with Gradle, use:

```bash
./gradlew run -PconfigPath=/path/to/config.sample.json -PoutputPath=/path/to/invitation-letter.pdf
./gradlew run --args="-c './config.sample.json' -o '.'"
```
Here,
- `configPath`: The path to the JSON file that contains configuration details.
- `outputPath`: The path where the generated PDF will be saved.

By default, the program will use the [`config.sample.json`](config.sample.json) located in the root dir and output the PDF file named `invitation-letter.pdf` in the root dir.
- `configPath`: Path to your JSON configuration file.
- `outputPath`: Destination for the generated PDF.

Alternatively, update the `gradle.properties` with your configuration and outputPath, then run:

Alternatively you can just change the configuration in the `gradle.properties` and execute:
```bash
./gradlew run
```

### Running the tests
You can run the tests using the following command:
#### Running Tests

Execute the test suite with:

```bash
./gradlew test
```

## Example of generated PDF (image)
## Example of Generated PDF (image)

Here's a preview of what the generated PDF looks like:

![pdf-sample.png](pdf-sample.png)
![Example PDF Output](pdf-sample.png)

## Credits
## Acknowledgments

* [Renato Araujo](https://www.linkedin.com/in/renatoraraujo/)
* Renato Araujo - [LinkedIn Profile](https://www.linkedin.com/in/renatoraraujo/)

## License

The MIT License (MIT) - see [`LICENSE`](LICENSE) for more details
This project is released under the MIT License - see the [LICENSE](LICENSE) file for details.

0 comments on commit 1ecb553

Please sign in to comment.