diff --git a/docs/plans/linux-backuper/00-status.md b/docs/plans/linux-backuper/00-status.md index 508d898..f71280c 100644 --- a/docs/plans/linux-backuper/00-status.md +++ b/docs/plans/linux-backuper/00-status.md @@ -13,7 +13,7 @@ - [ ] Slice 5 — retention policy & pruning engine (`--keep-last`, `--keep-daily`, automated cleanup) - [ ] Slice 6 — remote destination engine (SFTP / SCP / rsync / NFS export sync) - [ ] Slice 7 — packaging & distribution (.deb, .rpm, .tar.gz standalone) -- [ ] Slice 8 — full documentation (user, admin & developer guides), man page (Section 8), CLI -h/--help & Gitea Actions CI/CD release workflow +- [ ] Slice 8 — full documentation (user, admin & developer guides), man page (Section 8), CLI -h/--help, shell tab completion (Bash/Zsh) & Gitea Actions CI/CD release workflow ## Notes for a fresh session - Project: Enterprise-grade Linux system snapshot and configuration backup utility. @@ -22,6 +22,10 @@ - Platforms: Debian 11/12, Ubuntu 20.04/22.04/24.04, RHEL 8/9, AlmaLinux 8/9, Rocky Linux 8/9, Fedora 39/40/41, Arch Linux. - Target Python runtime: Python >= 3.6 (RHEL 8 compatibility). - Dependencies: Zero mandatory external dependencies (pure Python standard library). Optional `cryptography` for encrypted snapshots. +- Shell Tab Completion Standard (Bash & Zsh): + - Subcommands and flags auto-completion (`snapshot`, `list`, `show`, `diff`, `verify`, `extract`, `prune`). + - Dynamic completion: `show`, `diff`, `verify`, `extract` auto-complete snapshot IDs from `/var/backups/linux-backuper/`. + - Built-in `linux-backuper completion [bash|zsh]` generator + system-wide package deployment (`/usr/share/bash-completion/completions/` and `/usr/share/zsh/site-functions/`). - Documentation Standard (Mandatory parity with linux-updater): - User Guide: `docs/user-guide.md` (comprehensive operator workflow and snapshot recovery). - Administrator Guide: `docs/admin-guide.md` (automation, systemd timer/cron setup, logrotate, monitoring, JSON parsing). diff --git a/docs/plans/linux-backuper/01-spec.md b/docs/plans/linux-backuper/01-spec.md index 27ed52c..f51d175 100644 --- a/docs/plans/linux-backuper/01-spec.md +++ b/docs/plans/linux-backuper/01-spec.md @@ -106,3 +106,19 @@ To guarantee consistency across the homelab tooling ecosystem, `linux-backuper` - Root `linux-backuper -h` outputs an intuitive summary of all sub-commands with usage hints. - Each sub-command (`snapshot -h`, `list -h`, `show -h`, `diff -h`, `verify -h`, `extract -h`, `prune -h`) provides full argument descriptions, default values, and concrete examples. +--- + +## 7. Shell Tab Completion (Bash & Zsh) +To provide a smooth, fast terminal experience in everyday administration, `linux-backuper` includes first-class shell completion: +1. **Command & Option Completion:** + - Hitting `Tab` after `linux-backuper ` suggests all sub-commands (`snapshot`, `list`, `show`, `diff`, `verify`, `extract`, `prune`, `completion`). + - Hitting `Tab` after flags suggests options (`--keep-last`, `--keep-daily`, `--paths`, `--json`, `--verbose`). +2. **Dynamic Context-Aware Completion:** + - `linux-backuper show ` $\rightarrow$ automatically inspects `/var/backups/linux-backuper/` and suggests available `snapshot_id` names. + - `linux-backuper diff ` $\rightarrow$ suggests available snapshot IDs for comparison. + - `linux-backuper extract ` $\rightarrow$ suggests snapshot IDs, and after `--file ` suggests archived files. +3. **On-Demand Script Generation & System Packaging:** + - Dedicated generator command: `linux-backuper completion [bash|zsh]` outputs ready-to-source completion scripts. + - System packages (`.deb` and `.rpm`) automatically install completions to `/usr/share/bash-completion/completions/linux-backuper` and `/usr/share/zsh/site-functions/_linux-backuper`. + + diff --git a/docs/plans/linux-backuper/03-program-design.md b/docs/plans/linux-backuper/03-program-design.md index 61bbe42..99abf8a 100644 --- a/docs/plans/linux-backuper/03-program-design.md +++ b/docs/plans/linux-backuper/03-program-design.md @@ -21,13 +21,19 @@ linux-backuper/ │ │ ├── archiver.py # Tar/gzip/zstd packaging & atomic write │ │ ├── manifest.py # Manifest generator, reader & validator │ │ ├── retention.py # Pruning calculation engine -│ │ └── diff.py # Snapshot comparison engine +│ │ ├── diff.py # Snapshot comparison engine +│ │ └── completion.py # Shell completion generator & dynamic snapshot resolver │ └── managers/ │ ├── __init__.py │ ├── base.py # BasePackageManager class │ ├── rpm.py # RPM/DNF/YUM inspector │ ├── dpkg.py # DPKG/APT inspector │ └── pacman.py # Pacman inspector +├── completions/ +│ ├── bash/ +│ │ └── linux-backuper # Native Bash tab completion script +│ └── zsh/ +│ └── _linux-backuper # Native Zsh tab completion function ├── packaging/ │ ├── build_packages.py # Standalone .deb, .rpm and .tar.gz generator │ ├── install.sh # Tarball installer script diff --git a/docs/plans/linux-backuper/04-slices.md b/docs/plans/linux-backuper/04-slices.md index 2709d90..f4fb29b 100644 --- a/docs/plans/linux-backuper/04-slices.md +++ b/docs/plans/linux-backuper/04-slices.md @@ -78,14 +78,17 @@ This roadmap defines the implementation order for `linux-backuper` in thin, inde --- -### Slice 8 — Full Documentation, Man Page, CLI Help & Gitea Actions CI/CD Workflow -- **Goal:** Production-ready release automation and complete operator, admin, and developer documentation. +### Slice 8 — Full Documentation, Man Page, CLI Help, Shell Tab Completion & Gitea Actions CI/CD Workflow +- **Goal:** Production-ready release automation, complete documentation triad, man page, and native Bash/Zsh tab completion. - **Components:** - `docs/user-guide.md`: Comprehensive operator scenarios, routine backups, inspection, diffing, and single-file extracts. - `docs/admin-guide.md`: Automation via systemd timer/cron, `/etc/logrotate.d/` rule, monitoring JSON integration, and remote SFTP/NFS retention. - `docs/developer-guide.md`: Internal architecture, extending package/storage managers, and testing runbook. - `man/linux-backuper.8`: Full UNIX Section 8 man page (`man 8 linux-backuper`). + - Shell Tab Completion: Native Bash (`completions/bash/linux-backuper`) and Zsh (`completions/zsh/_linux-backuper`) scripts supporting subcommands, flags, and dynamic snapshot ID completion. + - `linux-backuper completion [bash|zsh]` generator sub-command. - Interactive CLI Help: Complete `-h` and `--help` for root and all sub-commands with usage examples. + - Packaging integration: Install completion scripts to `/usr/share/bash-completion/completions/` and `/usr/share/zsh/site-functions/`. - `.gitea/workflows/release.yml`: Gitea Actions pipeline targeting `runs-on: fedora`, running tests, building `.rpm`/`.deb`, publishing to Gitea Package Registry and Release assets. -- **Verification:** Unit tests verifying `linux-backuper -h` and each sub-command `--help` return exit code 0; man page syntax verified with `man -l man/linux-backuper.8`. +- **Verification:** Unit tests verifying `linux-backuper -h`, sub-command `--help`, shell completion scripts generation (`linux-backuper completion bash` / `zsh`), and man page syntax verification with `man -l man/linux-backuper.8`.