]> git.hungrycats.org Git - bees/commitdiff
usage: convert .txt+generator to a plain .cc raw-string literal
authorZygo Blaxell <bees@furryterror.org>
Sun, 26 Apr 2026 20:28:42 +0000 (16:28 -0400)
committerZygo Blaxell <bees@furryterror.org>
Tue, 6 Oct 2026 05:51:40 +0000 (01:51 -0400)
The previous approach generated bees-usage.c from bees-usage.txt via a
make rule using sed.  That added a generated C file to the build, which
did not survive 'git clean' without first re-running make.  It also
made the usage text invisible to grep and git log -p without escaping.

Replace bees-usage.txt + the make generator rule with a plain .cc file
containing a single raw-string literal assigned to BEES_USAGE.  The
file follows the same pattern as bees-config-v1.cc and compiles via the
existing %.cc pattern rule in src/Makefile without special treatment.

No behaviour change: the string stored in BEES_USAGE is identical to
the previous generated output.  The --help output is byte-identical.

Assisted-by: Claude-Code:claude-sonnet-4-6
Signed-off-by: Zygo Blaxell <bees@furryterror.org>
src/Makefile
src/bees-usage.cc [new file with mode: 0644]
src/bees-usage.txt [deleted file]

index e23e05bc5932c61a2acc93d62368883b667e8d35..ea5b87a31ed39fd74729fa5889aade8e123c461c 100644 (file)
@@ -22,6 +22,7 @@ BEES_OBJS = \
        bees.o \
        bees-config-v1.o \
        bees-config.o \
+       bees-usage.o \
        bees-context.o \
        bees-fdcache.o \
        bees-hash.o \
@@ -44,9 +45,6 @@ bees-version.c: FORCE
        printf 'const char *BEES_VERSION = "%s";\n' "$$(BEES_VERSION="$(BEES_VERSION)" ../scripts/bees-version .. | sed 's/\\/\\\\/g;s/"/\\"/g')" > bees-version.c.new
        if ! [ -e "$@" ] || ! cmp -s "$@.new" "$@"; then mv -fv $@.new $@; else rm -f $@.new; fi
 
-bees-usage.c: bees-usage.txt Makefile
-       (echo 'const char *BEES_USAGE = '; sed -r 's/^(.*)$$/"\1\\n"/' < bees-usage.txt; echo ';') > bees-usage.new.c
-       mv -f bees-usage.new.c bees-usage.c
 
 # The generated dependencies name the compiler's own header paths, so they are
 # stale after a toolchain switch too.  These files are `include'd, not
@@ -63,7 +61,7 @@ include $(ALL_OBJS:%.o=%.dep)
 %.o: %.cc $(BUILD_CONF)
        $(CXX) $(BEES_CXXFLAGS) -o $@ -c $<
 
-$(BEES): $(BEES_OBJS) bees-version.o bees-usage.o ../lib/libcrucible.a
+$(BEES): $(BEES_OBJS) bees-version.o ../lib/libcrucible.a
        $(CXX) $(BEES_CXXFLAGS) $(BEES_LDFLAGS) -o $@ $^ $(LIBS)
 
 clean:
diff --git a/src/bees-usage.cc b/src/bees-usage.cc
new file mode 100644 (file)
index 0000000..2b0c115
--- /dev/null
@@ -0,0 +1,76 @@
+/// @file bees-usage.cc
+/// Usage / help text for the bees binary.
+///
+/// Kept as a raw-string literal to avoid a Makefile text-generation step and
+/// to make the string visible to tools (grep, git log -p) without escaping.
+
+const char *BEES_USAGE = R"(Usage: %s [options] fs-root-path
+Performs best-effort extent-same deduplication on btrfs.
+
+fs-root-path MUST be the root of a btrfs filesystem tree (subvol id 5).
+Other directories will be rejected.
+
+Options:
+    -h, --help            Show this help and exit
+        --version         Print version information and exit
+
+        --config FILE     Read configuration options from FILE
+    -o, --option          Set one configuration option in `key=value` format
+
+Configuration debug options:
+        --write-trusted-config FILE
+                          Dump the merged trusted configuration view to FILE
+                          and exit without running dedupe.  FILE may be '-'
+                          for stdout.  Trusted view: only config files loaded
+                          from absolute paths can override [paths] keys.
+                          See `docs/options.md` for details.
+
+        --write-untrusted-config FILE
+                          Dump the merged untrusted configuration view to FILE
+                          and exit without running dedupe.  FILE may be '-'
+                          for stdout.  Untrusted view: all sources (including
+                          relative-path local config files) are included.
+                          See `docs/options.md` for details.
+
+Load management options:
+    -c, --thread-count    Exact worker thread count (overrides factor)
+                          [thread.thread-max]
+    -C, --thread-factor   Worker thread factor: threads per CPU (default 1)
+                          [thread.thread-factor]
+    -G, --thread-min      Minimum worker thread count (default 0)
+                          [thread.thread-min]
+    -g, --loadavg-target  Target load average for worker threads (default none)
+                          [thread.loadavg-target]
+        --throttle-factor Idle time between operations (default 1.0)
+                          [throttle.factor]
+
+Filesystem tree traversal options:
+    -m, --scan-mode MODE  Scanning mode (0..4, default 4)
+                         0..3: subvol scan [scan.subvol.active=yes, scan.subvol.mode=N, scan.extent.*.active=no]
+                         4: extent scan    [scan.subvol.active=no, scan.extent.*.active=yes]
+
+Workarounds:
+    -a, --workaround-btrfs-send    Workaround for btrfs send
+                                   (ignore RO snapshots)
+
+Logging options:
+    -t, --timestamps      Show timestamps in log output (default)
+                          [log.timestamps = yes]
+    -T, --no-timestamps   Omit timestamps in log output
+                          [log.timestamps = no]
+    -p, --absolute-paths  Show absolute paths (default)
+                          [log.strip-paths = no]
+    -P, --strip-paths     Strip fs-root-path from beginning of all paths in the log
+                          [log.strip-paths = yes]
+    -v, --verbose N       Set maximum log level (0..8, default 8)
+                          [log.level]
+
+Optional environment variables:
+    BEESHOME    Path to hash table and checkpoint files
+                (default is .beeshome/ in the root of the filesystem).
+                [path.home]
+
+    BEESSTATUS  Compatibility shortcut for report.legacy.filename and
+                report.legacy.active=yes.
+                [report.legacy.filename] [report.legacy.active]
+)";
diff --git a/src/bees-usage.txt b/src/bees-usage.txt
deleted file mode 100644 (file)
index 70a1ead..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-Usage: %s [options] fs-root-path
-Performs best-effort extent-same deduplication on btrfs.
-
-fs-root-path MUST be the root of a btrfs filesystem tree (subvol id 5).
-Other directories will be rejected.
-
-Options:
-    -h, --help            Show this help and exit
-        --version         Print version information and exit
-
-        --config FILE     Read configuration options from FILE
-    -o, --option          Set one configuration option in `key=value` format
-
-Load management options:
-    -c, --thread-count    Exact worker thread count (overrides factor)
-                          [thread.thread-max]
-    -C, --thread-factor   Worker thread factor: threads per CPU (default 1)
-                          [thread.thread-factor]
-    -G, --thread-min      Minimum worker thread count (default 0)
-                          [thread.thread-min]
-    -g, --loadavg-target  Target load average for worker threads (default none)
-                          [thread.loadavg-target]
-        --throttle-factor Idle time between operations (default 1.0)
-                          [throttle.factor]
-
-Filesystem tree traversal options:
-    -m, --scan-mode MODE  Scanning mode (0..4, default 4)
-                         0..3: subvol scan [scan.subvol.active=yes, scan.subvol.mode=N, scan.extent.*.active=no]
-                         4: extent scan    [scan.subvol.active=no, scan.extent.*.active=yes]
-
-Workarounds:
-    -a, --workaround-btrfs-send    Workaround for btrfs send
-                                   (ignore RO snapshots)
-
-Logging options:
-    -t, --timestamps      Show timestamps in log output (default)
-                          [log.timestamps = yes]
-    -T, --no-timestamps   Omit timestamps in log output
-                          [log.timestamps = no]
-    -p, --absolute-paths  Show absolute paths (default)
-                          [log.strip-paths = no]
-    -P, --strip-paths     Strip fs-root-path from beginning of all paths in the log
-                          [log.strip-paths = yes]
-    -v, --verbose N       Set maximum log level (0..8, default 8)
-                          [log.level]
-
-Optional environment variables:
-    BEESHOME    Path to hash table and checkpoint files
-                (default is .beeshome/ in the root of the filesystem).
-                [path.home]
-
-    BEESSTATUS  Compatibility shortcut for report.legacy.filename and
-                report.legacy.active=yes.
-                [report.legacy.filename] [report.legacy.active]