# kugiri
Marker-based block editing CLI for maintaining sections in text files.
## Installation
### Quick Install
Install the latest release:
```bash
Or run without installation:
```bash
# Pass arguments to kugiri (use -s -- to pass arguments)
### Install Specific Version
```bash
VERSION="v0.2.1"
### Secure Installation with Verification
For enhanced security, verify the installation scripts before executing them.
<details>
<summary><b>🔒 Verify latest version with Cosign</b></summary>
```bash
SCRIPT="install.sh" # or "run.sh"
DOWNLOAD_URL="https://github.com/actionutils/kugiri/releases/latest/download"
curl -sL "${DOWNLOAD_URL}/${SCRIPT}" | \
(tmpfile=$(mktemp); cat > "$tmpfile"; \
cosign verify-blob \
--certificate-identity-regexp '^https://github.com/actionutils/trusted-go-releaser/.github/workflows/trusted-release-workflow.yml@.*$' \
--certificate-oidc-issuer 'https://token.actions.githubusercontent.com' \
--certificate "${DOWNLOAD_URL}/${SCRIPT}.pem" \
--signature "${DOWNLOAD_URL}/${SCRIPT}.sig" \
"$tmpfile" && \
sh "$tmpfile"; rm -f "$tmpfile")
```
</details>
<details>
<summary><b>🔒 Verify specific version with Cosign</b></summary>
```bash
VERSION="v0.2.1"
SCRIPT="install.sh" # or "run.sh"
DOWNLOAD_URL="https://github.com/actionutils/kugiri/releases/download/${VERSION}"
curl -sL "${DOWNLOAD_URL}/${SCRIPT}" | \
(tmpfile=$(mktemp); cat > "$tmpfile"; \
cosign verify-blob \
--certificate-identity-regexp '^https://github.com/actionutils/trusted-go-releaser/.github/workflows/trusted-release-workflow.yml@.*$' \
--certificate-oidc-issuer 'https://token.actions.githubusercontent.com' \
--certificate "${DOWNLOAD_URL}/${SCRIPT}.pem" \
--signature "${DOWNLOAD_URL}/${SCRIPT}.sig" \
"$tmpfile" && \
sh "$tmpfile"; rm -f "$tmpfile")
```
</details>
<details>
<summary><b>🔒 Verify latest version with GitHub CLI</b></summary>
```bash
gh attestation verify --repo=actionutils/kugiri \
--signer-workflow='actionutils/trusted-go-releaser/.github/workflows/trusted-release-workflow.yml' \
"$tmpfile" && \
sh "$tmpfile"; rm -f "$tmpfile")
```
</details>
<details>
<summary><b>🔒 Verify specific version with GitHub CLI</b></summary>
```bash
VERSION="v0.2.1"
gh attestation verify --repo=actionutils/kugiri \
--signer-workflow='actionutils/trusted-go-releaser/.github/workflows/trusted-release-workflow.yml' \
"$tmpfile" && \
sh "$tmpfile"; rm -f "$tmpfile")
```
</details>
### Install from crates.io
If you have Rust and Cargo installed:
```bash
cargo install kugiri
```
## Usage
kugiri uses markers to identify sections in files:
- `<!-- KUGIRI-BEGIN: {id} -->` - Start of a section
- `<!-- KUGIRI-END: {id} -->` - End of a section
- `<!-- KUGIRI-INSERT: {id} -->` - Insertion point marker
### Commands
#### Insert
Add a new section before or after an existing marker:
```bash
# Insert after a marker
kugiri insert CHANGELOG.md --id v1.0.0 --after HEADER --body-file release.md -w
# Insert before a marker with content from stdin
#### Update
Replace the content of an existing section:
```bash
# Update section from file
kugiri update README.md --id help-section --body-file help.txt -w
# Update from stdin
#### Remove
Remove a section and its markers:
```bash
kugiri remove README.md --id deprecated-section -w
```
#### Extract
Print the content of a section (without markers):
```bash
kugiri extract README.md --id help-section > help.txt
```
#### Trim
Remove all KUGIRI markers from a file:
```bash
kugiri trim README.md > clean.md
```
#### Wrap
Wrap content with KUGIRI markers:
```bash
# Wrap stdin content
# Wrap content from a file
kugiri wrap --id section-name --body-file content.txt
```
### Options
- `-w, --write`: Write changes in-place (default: output to stdout)
- `--body-file <PATH|->`: Content source file (default: `-` for stdin)
- `--before <ID>`: Insert before this marker ID
- `--after <ID>`: Insert after this marker ID
- `--id <ID>`: Section identifier
## Examples
### Managing a CHANGELOG
```bash
# First release
# Subsequent releases
```
### Updating generated documentation
```bash
# Generate and update help section
# Extract for separate file
kugiri extract README.md --id CLI-HELP > docs/cli.md
```
## License
MIT