commit c81c319276c778ed8056c153d71ea07aea19b841
parent f4610d5adb3d3472f9c21d68f131561f516c0880
Author: Andrew Laack <andrew@laack.co>
Date: Wed, 16 Sep 2026 11:07:51 -0500
Added man page installation, updated readme, fixed cli edge cases.
Diffstat:
5 files changed, 64 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
@@ -3,7 +3,11 @@ include config.mk
# building actual program
build:
${COMMAND_P} src/main.cpp ${COMMAND_S} -o abg.out
-install: build
+man:
+ mkdir -p ${MANPREFIX}/man1
+ sed "s/VERSION/${VERSION}/g" < abg.1 > ${DESTDIR}${MANPREFIX}/man1/abg.1
+ chmod 644 ${DESTDIR}${MANPREFIX}/man1/abg.1
+install: build man
cp abg.out /usr/local/bin/abg
clean:
rm abg.out
diff --git a/README b/README
@@ -10,12 +10,13 @@ X11, raylib, g++, make
Usage
=====
- Usage: abg [--help] [--version] [--vertices VAR] [--edges VAR]
+ Usage: abg [--help] [--version] [--vertices VAR] [--sleep VAR] [--edges VAR]
Optional arguments:
-h, --help shows help message and exits
-v, --version prints version information and exits
--vertices number of vertices in the graph [nargs=0..1] [default: 200]
+ -s, --sleep amount of time to sleep between traversals [nargs=0..1] [default: 1]
-e, --edges number of edges in the graph [nargs=0..1] [default: 1000]
diff --git a/abg.1 b/abg.1
@@ -0,0 +1,37 @@
+.TH abg 1 abg\-VERSION
+.SH NAME
+abg \- animated background
+.SH SYNOPSIS
+.B abg [--help] [--version] [--vertices VAR] [--sleep VAR] [--edges VAR]
+.SH DESCRIPTION
+abg is a program that executes Prim's algorithm, rendering each step using raylib, set as an X11 background.
+.SH OPTIONS
+.TP
+.B -h, --help \n
+shows help message and exits
+
+.TP
+.B -v, --version
+prints version information and exits
+
+.TP
+.B --vertices
+number of vertices in the graph [nargs=0..1] [default: 200]
+
+.TP
+.B -s, --sleep
+amount of time to sleep between traversals [nargs=0..1] [default: 1]
+
+.TP
+.B -e, --edges
+number of edges in the graph [nargs=0..1] [default: 1000]
+
+prints version information to stderr, then exits.
+.SH EXAMPLES
+
+abg --vertices 10 --edges 20
+
+abg --vertices 300 --edges 2000 --sleep 3
+
+.SH BUGS
+Send all bug reports with a patch to andrew@laack.co.
diff --git a/config.mk b/config.mk
@@ -2,8 +2,7 @@ VERSION = 10.0.0
# dirs
PREFIX = /usr/local
-# TODO
-# MANPREFIX = ${PREFIX}/share/man
+MANPREFIX = ${PREFIX}/share/man
# linking
LIBS = -lraylib -lX11
diff --git a/src/main.cpp b/src/main.cpp
@@ -32,7 +32,7 @@ int main(int argc, char** argv) {
.default_value(DEFAULT_SLEEP_TIME)
.scan<'g', float>();
- // edges != total number of unique edges where uniqueness is defined by
+ // edges != total number of unique edges in all cases where uniqueness is defined by
// vertices this is because we allow multiple edges between two vertices
// (though they aren't rendered differently) we don't allow self-edges
// though.
@@ -54,6 +54,24 @@ int main(int argc, char** argv) {
std::size_t edgeCount = program.get<std::size_t>("--edges");
float sleepTime = program.get<float>("--sleep");
+ if(sleepTime < 0) {
+ std::cout << "Sleep time must be >= 0." << std::endl;
+ return -1;
+ }
+ if(vertexCount == 0) {
+ std::cout << "Vertex count must be >= 1" << std::endl;
+ return -1;
+ }
+ if(edgeCount == 0) {
+ std::cout << "Edge count must be >= 1" << std::endl;
+ return -1;
+ }
+ if(edgeCount > 0 && vertexCount <= 1) {
+ std::cout << "Not enough vertices to create any edges." << std::endl;
+ return -1;
+ }
+
+
SetTraceLogLevel(LOG_ERROR);
auto ss = getScreenSize();