f234e16e80
In clap 3.0, it's no longer possible to get `App::write_long_help` to output colorized text (it doesn't invoke the Colorizer at all). So let's move the generation outside of Rust.
30 lines
692 B
Nix
30 lines
692 B
Nix
{ runCommand, colmena, ansi2html }:
|
|
|
|
with builtins;
|
|
|
|
let
|
|
subcommands = [
|
|
null
|
|
"apply"
|
|
"apply-local"
|
|
"build"
|
|
"upload-keys"
|
|
"eval"
|
|
"exec"
|
|
"nix-info"
|
|
];
|
|
renderHelp = subcommand: let
|
|
fullCommand = if subcommand == null then "colmena" else "colmena ${subcommand}";
|
|
in ''
|
|
(
|
|
echo '## `${fullCommand}`'
|
|
echo -n '<pre><div class="hljs">'
|
|
TERM=xterm-256color CLICOLOR_FORCE=1 ${fullCommand} --help | ansi2html -p
|
|
echo '</div></pre>'
|
|
)>>$out
|
|
'';
|
|
in runCommand "colmena-colorized-help" {
|
|
nativeBuildInputs = [ colmena ansi2html ];
|
|
} (''
|
|
ansi2html -H > $out
|
|
'' + concatStringsSep "\n" (map renderHelp subcommands))
|