Skip to content

CodeSencor/CatfactCollector

Repository files navigation

CatfactCollector

.NET Build, Package and Release Latest Release

A .NET console application to fetch and store interesting cat facts. It features a generic host service architecture, file IO, basic logging, error handling and unit testing.

✨ Features

  • Fetches random cat facts from an online API.
  • Cross-platform: Standalone executables for Windows, Linux, and macOS.
  • Automated builds and releases are handled by GitHub Actions.

🚀 Getting Started

You can download the latest pre-compiled executables for your operating system from the Releases page.

Usage

  1. Download the appropriate executable for your system (e.g., CatfactCollector-win-x64.exe for Windows).
  2. Open a terminal or command prompt.
  3. Run the executable.

For Linux/macOS:

You may need to make the file executable first:

chmod +x ./CatfactCollector-linux-x64
./CatfactCollector-linux-x64

For Windows:

./CatfactCollector-win-x64.exe

Command-line Arguments

The application can be configured via an appsettings.json file placed in the same directory as the executable. The sample appsettings.json can be found here. Alternatively, you can use command-line arguments to override these settings or run the application without an appsettings.json file altogether.

Flag Alias Description Required (if not in appsettings.json)
--loglevel -l Sets the logging level (e.g., Information, Debug, Error). No (defaults to Information)
--output -o Specifies the path to the output file where cat facts will be saved. Yes
--endpoint -e Sets the base URL for the cat fact API. No (defaults to https://catfact.ninja/)
--path -p Sets the relative path for the API endpoint. No (defaults to fact)
--timeout -t Sets the HTTP request timeout in seconds. No (defaults to 5 seconds)
--interval -i Sets the interval in seconds for fetching new cat facts. No (defaults to 5 seconds)

Example:

Run the application with a 10-second interval, a 15-second timeout, a custom API path, debug logging, and save the facts to a custom file named my-cat-facts.txt.

# For Linux/macOS
./CatfactCollector-linux-x64 --interval 10 --output my-cat-facts.txt --loglevel Debug --timeout 15 --path "facts"

# For Windows
./CatfactCollector-win-x64.exe --interval 10 --output my-cat-facts.txt --loglevel Debug --timeout 15 --path "facts"

🛠️ Building from Source

If you prefer to build the project yourself, follow these steps.

Prerequisites

Instructions

  1. Clone the repository:

    git clone https://github.com/your-username/your-repository.git
    cd CatfactCollector
  2. Restore dependencies:

    dotnet restore
  3. Run the application:

    dotnet run --project CatfactCollector

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages