From b1644de411d789cb337ac250913a8aad2d53b40d Mon Sep 17 00:00:00 2001 From: "Max P." Date: Wed, 2 Jul 2025 13:55:58 +0200 Subject: [PATCH] docs(script): improve help message layout and readability - Revamps the script's help message for better clarity and usability - Consolidates and restructures usage, options, and arguments sections - Simplifies help text generation using `sed` to avoid redundancy --- scripts/install-git-cliff.sh | 62 +++++++++++++----------------------- 1 file changed, 23 insertions(+), 39 deletions(-) diff --git a/scripts/install-git-cliff.sh b/scripts/install-git-cliff.sh index 6edf4a9..323043f 100755 --- a/scripts/install-git-cliff.sh +++ b/scripts/install-git-cliff.sh @@ -1,17 +1,27 @@ #!/usr/bin/env bash -# install-git-cliff.sh – fetches the latest or specified git-cliff binary -# Usage (back-compatible): -# sudo ./install-git-cliff.sh # latest version, default arch/dir -# sudo ./install-git-cliff.sh 2.9.1 # specific version -# Extended options: -# sudo ./install-git-cliff.sh -a x86_64-linux-musl [] # custom arch -# sudo ./install-git-cliff.sh -d /opt/tools [] # custom install dir -# sudo ./install-git-cliff.sh -n [] # dry-run (no install) -# sudo ./install-git-cliff.sh -h | --help # help -# +# install-git-cliff.sh – Installs the git-cliff binary + +# Usage: +# sudo ./install-git-cliff.sh [options] [] + +# Options: +# -a, --arch Target architecture (default: ${DEFAULT_ARCH_DISPLAY}) +# -d, --dir Installation directory (default: ${INSTALL_DIR_DEFAULT}) +# -n, --dry-run Download and verify, but do NOT install +# -h, --help Show this help message + +# Arguments: +# git-cliff version to install (default: latest) + # Behaviour: -# • If git-cliff is already in \$PATH and **no version** was requested, the script exits early. -# • If a specific version was requested, the installed version is compared; identical → exit, different → upgrade. +# • If git-cliff is already in PATH and no version was requested the script exits. +# • If a specific version was requested, the installed version is compared and +# only upgraded if it differs. + +# Supported architecture triplets (examples): +# aarch64-linux-gnu / musl / apple-darwin / pc-windows-msvc +# i686-linux-gnu / musl / pc-windows-msvc +# x86_64-linux-gnu / musl / apple-darwin / pc-windows-* set -euo pipefail REPO="orhun/git-cliff" @@ -29,33 +39,7 @@ USER_VERSION_SPECIFIED=false # ─────────────────────────────────────────────── # 0 Help function -show_help() { - cat <] - -Options: - -a, --arch Target architecture (default: ${DEFAULT_ARCH_DISPLAY}) - -d, --dir Installation directory (default: ${INSTALL_DIR_DEFAULT}) - -n, --dry-run Download and verify, but do NOT install - -h, --help Show this help message - -Arguments: - git-cliff version to install (default: latest) - -Behaviour: - • If git-cliff is already in PATH and no version was requested the script exits. - • If a specific version was requested, the installed version is compared and - only upgraded if it differs. - -Supported architecture triplets (examples): - aarch64-linux-gnu / musl / apple-darwin / pc-windows-msvc - i686-linux-gnu / musl / pc-windows-msvc - x86_64-linux-gnu / musl / apple-darwin / pc-windows-* -EOF -} +show_help() { sed -n '2,24p' "$0"; } # 1 Parse options (keeps old single-arg form) POSITIONAL=()