From 82cbc580dcb5528d1399a88e761b0995acefa445 Mon Sep 17 00:00:00 2001 From: Bauke Date: Sun, 6 Nov 2022 18:46:28 +0100 Subject: [PATCH] Use the generate CLI reference. --- hooked-book/source/cli-reference.txt | 42 ++++++++++++++++++++++++++++ hooked-book/source/cli/install.md | 11 +------- hooked-book/source/cli/run.md | 15 ++-------- hooked-book/source/cli/uninstall.md | 11 +------- 4 files changed, 46 insertions(+), 33 deletions(-) create mode 100644 hooked-book/source/cli-reference.txt diff --git a/hooked-book/source/cli-reference.txt b/hooked-book/source/cli-reference.txt new file mode 100644 index 0000000..4cc7cf6 --- /dev/null +++ b/hooked-book/source/cli-reference.txt @@ -0,0 +1,42 @@ +This file is automatically generated using the cli-reference subcommand. +Use `cargo run -- cli-reference` to generate it. + +// ANCHOR: install +$ hooked install --help +Install Hooked into ".git/hooks" + +Usage: hooked install [OPTIONS] + +Options: + --overwrite Overwrite existing files + -c, --config Path to a Hooked configuration [default: Hooked.toml] + -h, --help Print help information + -V, --version Print version information +// ANCHOR_END: install +// ANCHOR: run +$ hooked run --help +Manually run hooks + +Usage: hooked run [OPTIONS] + +Arguments: + The hook type to run [possible values: pre-commit] + +Options: + -c, --config Path to a Hooked configuration [default: Hooked.toml] + -h, --help Print help information + -V, --version Print version information +// ANCHOR_END: run +// ANCHOR: uninstall +$ hooked uninstall --help +Remove installed hooks + +Usage: hooked uninstall [OPTIONS] + +Options: + --all Remove hooks not installed by Hooked + -c, --config Path to a Hooked configuration [default: Hooked.toml] + -h, --help Print help information + -V, --version Print version information +// ANCHOR_END: uninstall + diff --git a/hooked-book/source/cli/install.md b/hooked-book/source/cli/install.md index 86b50e5..677399e 100644 --- a/hooked-book/source/cli/install.md +++ b/hooked-book/source/cli/install.md @@ -3,16 +3,7 @@ The `install` command creates the scripts inside `.git/hooks`. ```sh -$ hooked install --help -Install Hooked into ".git/hooks" - -Usage: hooked install [OPTIONS] - -Options: - --overwrite Overwrite existing files - -c, --config Path to a Hooked configuration [default: Hooked.toml] - -h, --help Print help information - -V, --version Print version information +{{#include ../cli-reference.txt:install}} ``` Below is the default script template that Hooked uses, where `hook_type` is the type of hook to run (like `pre-commit`) and `config_path` is the `general.config` field from the parsed configuration. diff --git a/hooked-book/source/cli/run.md b/hooked-book/source/cli/run.md index f0272b4..c82f53c 100644 --- a/hooked-book/source/cli/run.md +++ b/hooked-book/source/cli/run.md @@ -2,17 +2,6 @@ The `run` command manually runs configured hooks. -``` -$ hooked run --help -Manually run hooks - -Usage: hooked run [OPTIONS] - -Arguments: - The hook type to run [possible values: pre-commit] - -Options: - -c, --config Path to a Hooked configuration [default: Hooked.toml] - -h, --help Print help information - -V, --version Print version information +```sh +{{#include ../cli-reference.txt:run}} ``` diff --git a/hooked-book/source/cli/uninstall.md b/hooked-book/source/cli/uninstall.md index 10d687f..addc196 100644 --- a/hooked-book/source/cli/uninstall.md +++ b/hooked-book/source/cli/uninstall.md @@ -3,16 +3,7 @@ The `uninstall` command removes script files inside `.git/hooks`. ```sh -hooked uninstall --help -Remove installed hooks - -Usage: hooked uninstall [OPTIONS] - -Options: - --all Remove hooks not installed by Hooked - -c, --config Path to a Hooked configuration [default: Hooked.toml] - -h, --help Print help information - -V, --version Print version information +{{#include ../cli-reference.txt:uninstall}} ``` By default Hooked will only remove scripts that have a `# Installed by Hooked.` line in them, using `--all` however will remove all script files.