Compare commits
5 Commits
e2c0294a5b
...
main
Author | SHA1 | Date | |
---|---|---|---|
6b162106e4 | |||
e9f8be5b2b
|
|||
6c8513fa58 | |||
e94fdbf837
|
|||
65e4092af2
|
@@ -9,14 +9,22 @@ All notable changes to this project will be documented in this file.
|
|||||||
- *(vscode)* Add custom activity bar color settings
|
- *(vscode)* Add custom activity bar color settings
|
||||||
- *(script)* Add installer for git-cliff binary
|
- *(script)* Add installer for git-cliff binary
|
||||||
- *(script)* Enhance git-cliff installer with extended options
|
- *(script)* Enhance git-cliff installer with extended options
|
||||||
|
- *(bash)* Add self-contained help extraction script
|
||||||
|
|
||||||
### 📚 Documentation
|
### 📚 Documentation
|
||||||
|
|
||||||
- *(readme)* Update title and add license link
|
- *(readme)* Update title and add license link
|
||||||
|
|
||||||
|
### 🎨 Styling
|
||||||
|
|
||||||
|
- *(bash)* Remove unnecessary space stripping in help output
|
||||||
|
|
||||||
### ⚙️ Miscellaneous Tasks
|
### ⚙️ Miscellaneous Tasks
|
||||||
|
|
||||||
- *(workflows)* Add release workflow and merge message template
|
- *(workflows)* Add release workflow and merge message template
|
||||||
- *(changelog)* Update unreleased changelog
|
- *(changelog)* Update unreleased changelog
|
||||||
|
- *(changelog)* Update unreleased changelog
|
||||||
|
- *(structure)* Reorganize install script location
|
||||||
|
- *(changelog)* Update unreleased changelog
|
||||||
|
|
||||||
<!-- generated by git-cliff -->
|
<!-- generated by git-cliff -->
|
||||||
|
52
snippets/bash/show_help.sh
Normal file
52
snippets/bash/show_help.sh
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# show_help.sh – Example Bash script with embedded help section
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
# Use this snippet as a pattern for Bash scripts that include their own help text
|
||||||
|
# inside comment blocks. The `show_help` function will extract the lines between
|
||||||
|
# `#=== HELP START ===` and `#=== HELP END ===`, strip the leading `#` and output
|
||||||
|
# a clean help message.
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
show_help() {
|
||||||
|
sed -n '/^#=== HELP START ===/,/^#=== HELP END ===/ {
|
||||||
|
/^#=== HELP START ===/d
|
||||||
|
/^#=== HELP END ===/d
|
||||||
|
s/^#//
|
||||||
|
p
|
||||||
|
}' "$0"
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- Example usage of the show_help function ---
|
||||||
|
|
||||||
|
#=== HELP START ===
|
||||||
|
# Example Script
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# ./show_help.sh [options]
|
||||||
|
#
|
||||||
|
# Options:
|
||||||
|
# -h, --help Show this help message and exit
|
||||||
|
# -v, --verbose Enable verbose output
|
||||||
|
#
|
||||||
|
# Description:
|
||||||
|
# This is an example of how to embed a self-contained help
|
||||||
|
# section in a Bash script using a simple sed-based extractor.
|
||||||
|
#=== HELP END ===
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
# Main entrypoint
|
||||||
|
case "$1" in
|
||||||
|
-h|--help)
|
||||||
|
show_help
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-v|--verbose)
|
||||||
|
echo "Verbose mode enabled"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Run with --help for usage."
|
||||||
|
;;
|
||||||
|
esac
|
Reference in New Issue
Block a user