Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: C++20 CI

on:
pull_request:
push:

jobs:
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
- name: Configure
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build build --config Release --parallel
- name: Test
run: ctest --test-dir build --output-on-failure
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
.idea/
*.exe
*.exe
build/
CMakeFiles/
CMakeCache.txt
cmake_install.cmake
CTestTestfile.cmake
Testing/
maifetch
maifetch_tests
target/
41 changes: 41 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
cmake_minimum_required(VERSION 3.20)

project(maifetch VERSION 0.2.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(CURL REQUIRED)

add_library(maifetch_core
src/maifetch.cpp
)

target_include_directories(maifetch_core PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
)

target_link_libraries(maifetch_core PUBLIC CURL::libcurl)

if(MSVC)
target_compile_options(maifetch_core PRIVATE /W4 /permissive-)
else()
target_compile_options(maifetch_core PRIVATE -Wall -Wextra -Wpedantic)
endif()

add_executable(maifetch
src/main.cpp
)

target_link_libraries(maifetch PRIVATE maifetch_core)

enable_testing()

add_executable(maifetch_tests
tests/maifetch_tests.cpp
)

target_link_libraries(maifetch_tests PRIVATE maifetch_core)

add_test(NAME maifetch_tests COMMAND maifetch_tests)
89 changes: 68 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,82 @@
# maifetch
a really lazy fetch tool for [maitea](https://maitea.app) written in go\
also contains a little api wrapper for maitea too :D

A lazy terminal fetch tool for [MaiTea](https://maitea.app), rewritten in modern C++20.

![image](https://github.com/user-attachments/assets/96cd7018-8a00-4785-a1a8-9fe503263662)

## configuration
## Features

- Fetches MaiTea profile information and recent plays with authenticated API requests.
- Preserves the existing config priority: CLI > environment > config file > defaults.
- Provides ANSI truecolor output with `--no-color` for plain terminals.
- Builds with CMake and C++20, with a small test executable for parser, config, and formatting behavior.

## Requirements

- A C++20 compiler
- CMake 3.20 or newer
- libcurl development headers

On Debian or Ubuntu:

```sh
sudo apt-get install cmake g++ libcurl4-openssl-dev
```

## Configuration

| variable | description | default | environment variable | cli argument |
|--------------|----------------------------------------------------|--------------------------------------------|----------------------|-----------------------|
| access token | token for your MaiTea account (REQUIRED) | `N/A` | `MAITEA_TOKEN` | `--access-token` `-a` |
| logo size | size of the ASCII logo (zero or negative disables) | `20` | `MAITEA_LOGO_SIZE` | `--logo-size` `-l` |
| score count | amount of scores to display (max 12) | `4` | `MAITEA_SCORE_COUNT` | `--score-count` `-s` |
| config file | json file to store config variables | [refer to below](#default-config-location) | `MAITEA_CONFIG_FILE` | `--config-file` `-c` |
| access token | token for your MaiTea account (required) | `N/A` | `MAIFETCH_TOKEN` or `MAITEA_TOKEN` | `--access-token` `-a` `-t` |
| logo size | size of the terminal logo, zero disables it | `20` | `MAIFETCH_LOGO_SIZE` or `MAITEA_LOGO_SIZE` | `--logo-size` `-l` |
| score count | amount of scores to display, max 12 | `4` | `MAIFETCH_SCORE_COUNT` or `MAITEA_SCORE_COUNT` | `--score-count` `-s` |
| API base URL | MaiTea API base URL, mostly useful for tests | `https://maitea.app` | `MAIFETCH_BASE_URL` or `MAITEA_BASE_URL` | `--base-url` |
| config file | JSON file to store config variables | [refer to below](#default-config-location) | `MAIFETCH_CONFIG_FILE` or `MAITEA_CONFIG_FILE` | `--config-file` `-c` |

### Default config location
obtained from `os.UserConfigDir`
Example config:

```json
{
"accessToken": "your-token",
"scoreCount": 4,
"logoSize": 20,
"baseUrl": "https://maitea.app"
}
```

### Default Config Location

| platform | location |
|----------|-------------------------------------------------------------|
| Windows | `%APPDATA%/maifetch.json` |
| Linux | `$XDG_CONFIG_HOME/maifetch.json` `~/.config/maifetch.json` |
| OSX | `~/Library/Application Support/maifetch.json` |
| Linux | `$XDG_CONFIG_HOME/maifetch.json` or `~/.config/maifetch.json` |
| macOS | `~/Library/Application Support/maifetch.json` |

## Build

```sh
git clone https://github.com/HutchyBen/maifetch
cd maifetch
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --parallel
```

Run the built executable:

```sh
./build/maifetch --access-token "$MAIFETCH_TOKEN"
```

On Windows, the executable path is usually:

```powershell
.\build\Release\maifetch.exe --access-token $env:MAIFETCH_TOKEN
```

## how to build
1. clone the project with `git clone https://github.com/HutchyBen/maifetch`
2. build with `go build maifetch/cmd/maifetch`
3. run outputted executable ensuring access token is either
- in config file
- in environment variables
- in command line options
## Test

```sh
ctest --test-dir build --output-on-failure
```

## todo
- test it properly
- add friendly errors
The test suite covers config priority, environment config-file selection, JSON parsing, and output formatting.
85 changes: 0 additions & 85 deletions cmd/maifetch/config.go

This file was deleted.

121 changes: 0 additions & 121 deletions cmd/maifetch/main.go

This file was deleted.

Loading