Add progress bar and structured logging
- Progress bar (deps/log.c submodule added): * Unicode block chars (██░░), braille spinner for indeterminate mode * Shows: percentage, found/total, seeds/sec (EMA), ETA * Auto-enables on TTY, suppressed when piped * Clears and redraws cleanly around log messages and matches - Logging via rxi/log.c: * Timestamped, colored levels: TRACE DEBUG INFO WARN ERROR FATAL * --log-level trace|debug|info|warn|error|off * --log-file FILE for persistent log (full timestamps, no colors) - New flags: --no-progress, --progress (force), --log-level, --log-file Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
843f1ce8f3
commit
14a294b768
5 changed files with 648 additions and 730 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -4,3 +4,6 @@
|
|||
[submodule "cubiomes"]
|
||||
path = cubiomes
|
||||
url = https://github.com/xpple/cubiomes.git
|
||||
[submodule "deps/log.c"]
|
||||
path = deps/log.c
|
||||
url = https://github.com/rxi/log.c.git
|
||||
|
|
|
|||
11
Makefile
11
Makefile
|
|
@ -20,18 +20,23 @@ CUBIOMES_SRCS = \
|
|||
|
||||
CUBIOMES_OBJS = $(CUBIOMES_SRCS:.c=.o)
|
||||
|
||||
LOG_OBJ = deps/log.c/src/log.o
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: celseed
|
||||
|
||||
celseed: celseed.o $(CUBIOMES_OBJS)
|
||||
celseed: celseed.o $(CUBIOMES_OBJS) $(LOG_OBJ)
|
||||
$(CC) -o $@ $^ -lm
|
||||
|
||||
celseed.o: celseed.c
|
||||
$(CC) $(CFLAGS) -Wno-format-truncation -Wno-stringop-truncation -c -o $@ $<
|
||||
$(CC) $(CFLAGS) -Wno-format-truncation -Wno-stringop-truncation -Wno-misleading-indentation -c -o $@ $<
|
||||
|
||||
$(CUBIOMES_OBJS): %.o: %.c
|
||||
$(CC) $(CFLAGS) -Icubiomes -w -c -o $@ $<
|
||||
|
||||
$(LOG_OBJ): deps/log.c/src/log.c
|
||||
$(CC) $(CFLAGS) -w -c -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f celseed celseed.o $(CUBIOMES_OBJS)
|
||||
rm -f celseed celseed.o $(CUBIOMES_OBJS) $(LOG_OBJ)
|
||||
|
|
|
|||
31
README.md
31
README.md
|
|
@ -18,6 +18,13 @@ make
|
|||
|
||||
The binary `celseed` is created in the project root.
|
||||
|
||||
### Dependencies (included as git submodules)
|
||||
|
||||
| Library | Purpose |
|
||||
|---------|---------|
|
||||
| [cubiomes](https://github.com/Cubitect/cubiomes) | Minecraft biome/structure generation |
|
||||
| [log.c](https://github.com/rxi/log.c) | Structured leveled logging |
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
|
@ -39,6 +46,10 @@ celseed [OPTIONS]
|
|||
| `--large` | off | Enable large biomes |
|
||||
| `--quiet` | off | Print only seed values |
|
||||
| `--verbose` | off | Print index alongside value |
|
||||
| `--log-level LEVEL` | `info` | Log verbosity: `trace` `debug` `info` `warn` `error` `off` |
|
||||
| `--log-file FILE` | *(none)* | Write full logs to FILE (always includes DEBUG+) |
|
||||
| `--no-progress` | off | Disable progress bar |
|
||||
| `--progress` | off | Force-enable progress bar (e.g. for recording) |
|
||||
| `--list-versions` | — | List all supported versions |
|
||||
|
||||
---
|
||||
|
|
@ -122,6 +133,11 @@ celseed --from -500000 --to 500000 --filter 'seed % 1000 == 0' --count 20
|
|||
32 chunks, i.e. 512 blocks, depending on structure type).
|
||||
- The filter syntax follows CEL principles; the evaluator is implemented
|
||||
in C as part of this tool (the `cel-c` submodule is included for reference).
|
||||
- The progress bar auto-enables when stderr is a terminal (TTY). It shows
|
||||
a Unicode block bar (`██░░`), seeds/second speed, found count, and ETA.
|
||||
- Logging uses [log.c](https://github.com/rxi/log.c) with timestamps and
|
||||
colors. Use `--log-file` to persist logs. Use `--log-level debug` for
|
||||
verbose output including expression parsing and generator setup.
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -150,6 +166,13 @@ make
|
|||
|
||||
В корне проекта появится исполняемый файл `celseed`.
|
||||
|
||||
### Зависимости (git submodule)
|
||||
|
||||
| Библиотека | Назначение |
|
||||
|------------|-----------|
|
||||
| [cubiomes](https://github.com/Cubitect/cubiomes) | Генерация биомов и структур Minecraft |
|
||||
| [log.c](https://github.com/rxi/log.c) | Структурированное логирование с уровнями |
|
||||
|
||||
---
|
||||
|
||||
## Использование
|
||||
|
|
@ -171,6 +194,10 @@ celseed [ОПЦИИ]
|
|||
| `--large` | выкл | Большие биомы |
|
||||
| `--quiet` | выкл | Печатать только значения сидов |
|
||||
| `--verbose` | выкл | Печатать индекс рядом со значением |
|
||||
| `--log-level LEVEL` | `info` | Уровень логов: `trace` `debug` `info` `warn` `error` `off` |
|
||||
| `--log-file FILE` | *(нет)* | Записывать логи в файл |
|
||||
| `--no-progress` | выкл | Отключить прогресс бар |
|
||||
| `--progress` | выкл | Принудительно включить прогресс бар |
|
||||
| `--list-versions` | — | Список поддерживаемых версий |
|
||||
|
||||
---
|
||||
|
|
@ -246,6 +273,10 @@ celseed --filter 'spawn_x() > -200 && spawn_x() < 200 && spawn_z() > -200 && spa
|
|||
- `x`, `z` в `biome()` и `has_biome()` — блочные координаты.
|
||||
- `rx`, `rz` в `structure()` — индексы регионов (обычно 32 чанка = 512 блоков).
|
||||
- Синтаксис фильтра следует принципам CEL; вычислитель реализован на C.
|
||||
- Прогресс бар автоматически включается когда stderr является терминалом.
|
||||
Отображает Unicode-бар (`██░░`), скорость (сидов/сек), счётчик найденных и ETA.
|
||||
- Логирование через [log.c](https://github.com/rxi/log.c): временные метки,
|
||||
цветовые уровни. `--log-file` — лог в файл, `--log-level debug` — подробный вывод.
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
1
deps/log.c
vendored
Submodule
1
deps/log.c
vendored
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit f9ea34994bd58ed342d2245cd4110bb5c6790153
|
||||
Loading…
Add table
Add a link
Reference in a new issue