docs: Generate manpages from docs, use in CLI

Change-Id: I6a6a69646c6ff4c4b70cb928dc1df06890144429
This commit is contained in:
puck 2025-06-23 12:22:20 +00:00
parent 5332df82bb
commit 30814de5e4
4 changed files with 26 additions and 45 deletions

View file

@ -3,6 +3,9 @@
(foreign-declare "#include \"stock_overrides.h\"")
(define stock-overrides (foreign-value "stock_overrides" nonnull-c-string))
(foreign-declare "#include \"man_rust.h\"")
(define man-page (foreign-value "man_rust" nonnull-c-string))
(define get-cpu-count
(foreign-lambda* int ()
"cpu_set_t set; sched_getaffinity(0, sizeof(set), &set); C_return(CPU_COUNT(&set));"))
@ -10,30 +13,7 @@
(define (print-help msg)
(when msg
(write-string (string-append msg "\n\n") (current-error-port)))
(write-string "Usage: zilch-cli-rust [OPTION] [TARGET...]
Process the given crate directory (or the current directory, if unspecified)
and output derivations for each target given on the command line (or all
executables in the crate, if unspecified)
-h, --help Print this help message.
-j, --max-jobs COUNT The maximum amount of builds to run. Defaults
to the amount of cores.
-v, --verbose Increase the verbosity configured in the Nix
daemon.
-L, --print-build-logs Print derivation logs as they come in.
-m, --crate-dir DIR The directory to use as root crate.
-r, --replace DIR Replace the crate specified by the Cargo.toml
with this source directory, rather than using
the upstream crate. Can be specified more
than once.
-z, --overrides PATH Read build script overrides from this file.
By default, a stock set of overrides is read.
This can be disabled by passing `-z \"\"`
(a blank string).
--debug Crash on the first error, rather than
continuing with the next package.
" (current-error-port))
(write-string man-page (current-error-port))
(exit (or (not msg) 1)))
(define-values (options args)