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
18 changes: 18 additions & 0 deletions .github/workflows/gnucobol.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# AI-assisted with OpenAI GPT-5 Codex.
name: GnuCOBOL

on:
push:
pull_request:

jobs:
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install GnuCOBOL
run: |
sudo apt-get update
sudo apt-get install -y gnucobol curl
- name: Build and test
run: make test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.idea/
*.exe
*.exe
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# AI-assisted with OpenAI GPT-5 Codex.

COBC ?= cobc
BUILD_DIR ?= build
TARGET ?= $(BUILD_DIR)/maifetch

.PHONY: all clean test

all: $(TARGET)

$(TARGET): src/maifetch.cob
mkdir -p $(BUILD_DIR)
$(COBC) -x -free -Wall -o $(TARGET) src/maifetch.cob

test: $(TARGET)
sh tests/run-fixture-test.sh $(TARGET)

clean:
rm -rf $(BUILD_DIR)
98 changes: 77 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,91 @@
<!-- AI-assisted with OpenAI GPT-5 Codex. -->
# 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
GnuCOBOL for the current bounty direction.

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

## configuration
## Features

- GnuCOBOL CLI implementation with no Go runtime dependency.
- Preserves the original configuration priority:
command line > environment > config file > defaults.
- Supports the original MaiTea config names and arguments:
`--access-token` / `-a` / `-t`, `--logo-size` / `-l`,
`--score-count` / `-s`, and `--config-file` / `-c`.
- Fetches `/api/v1/profiles` and `/api/v1/plays` with authenticated `curl`
requests, then formats the same profile and recent-score fields as the Go
version.
- Includes fixture-driven tests so CI can validate CLI parsing, JSON field
extraction, output formatting, and the no-token error path without a live
MaiTea token.

## Requirements

- GnuCOBOL 3.x or newer
- `curl` for live MaiTea API requests

On Debian or Ubuntu:

```sh
sudo apt-get update
sudo apt-get install -y gnucobol curl
```

## 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` | `MAITEA_TOKEN` | `--access-token` `-a` `-t` |
| 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` |

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

```json
{
"accessToken": "your-token",
"scoreCount": 4,
"logoSize": 20
}
```

### Default Config Location

The COBOL rewrite follows the same practical defaults as the original Go
implementation:

| 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
make
```

Run the built executable:

```sh
./build/maifetch --access-token "$MAITEA_TOKEN" --logo-size 0
```

`--logo-size 0` disables the profile icon area, matching the original tool's
no-logo mode. The COBOL implementation keeps a blank logo column when a
positive logo size is configured because the original Go image-to-ASCII library
does not have a direct GnuCOBOL equivalent.

## 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
make test
```

## todo
- test it properly
- add friendly errors
The test suite compiles the GnuCOBOL program and runs it against checked-in
MaiTea JSON fixtures via `MAIFETCH_PROFILE_FIXTURE` and
`MAIFETCH_PLAYS_FIXTURE`, avoiding any live network credentials in CI.
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