Skip to content

Commit 621afd0

Browse files
alexey1312claude
andauthored
Add Usage CLI spec for shell completions and docs (#69)
* feat: add Usage CLI spec for shell completions and docs Add exfig.usage.kdl with full specification of all 19 CLI commands, flags, and arguments. This enables generating shell completions (bash/zsh/fish) and markdown documentation from a single source of truth. - Add usage tool to mise.toml with completions and docs tasks - Generate and attach shell completions as GitHub Release assets - Update CLAUDE.md with completions commands and KDL sync reminder Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: harden release workflow and fix Usage spec inaccuracies Pin usage tool to v2.18.2 in both mise.toml and release workflow, add --fail/pipefail to curl, validate generated completion files are non-empty. Fix version prefix (v2.8.0) and schemas default path in exfig.usage.kdl. Add version sync reminder to CLAUDE.md. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: improve filter argument help texts in Usage spec Match the Swift source help descriptions with single/multiple/wildcard examples for colors, icons, and images filter arguments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 48c081c commit 621afd0

5 files changed

Lines changed: 391 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,24 @@ jobs:
192192
--output-path ".pkl-out/%{name}@%{version}/" \
193193
Sources/ExFigCLI/Resources/Schemas
194194
195+
- name: Generate shell completions
196+
run: |
197+
set -euo pipefail
198+
USAGE_VERSION="2.18.2"
199+
curl --fail -sL "https://github.com/jdx/usage/releases/download/v${USAGE_VERSION}/usage-x86_64-unknown-linux-gnu.tar.gz" -o usage.tar.gz
200+
tar xzf usage.tar.gz
201+
chmod +x usage/bin/usage
202+
mkdir -p completions
203+
usage/bin/usage generate completion bash exfig -f exfig.usage.kdl > completions/exfig.bash
204+
usage/bin/usage generate completion zsh exfig -f exfig.usage.kdl > completions/_exfig
205+
usage/bin/usage generate completion fish exfig -f exfig.usage.kdl > completions/exfig.fish
206+
for f in completions/exfig.bash completions/_exfig completions/exfig.fish; do
207+
if [[ ! -s "$f" ]]; then
208+
echo "::error::Generated completion file is empty: $f"
209+
exit 1
210+
fi
211+
done
212+
195213
- name: Create GitHub Release
196214
uses: softprops/action-gh-release@v2
197215
with:
@@ -201,6 +219,9 @@ jobs:
201219
artifacts/exfig-macos/exfig-macos.zip
202220
artifacts/exfig-linux-x64/exfig-linux-x64.tar.gz
203221
.pkl-out/exfig@*/*
222+
completions/exfig.bash
223+
completions/_exfig
224+
completions/exfig.fish
204225
205226
update-homebrew:
206227
name: Update Homebrew Tap

CLAUDE.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ and Flutter projects.
8787
./bin/mise run clean # Clean build artifacts
8888
./bin/mise run clean:all # Clean build + derived data
8989

90+
# Shell Completions & CLI Docs (via Usage spec)
91+
./bin/mise run completions:bash # Generate bash completions
92+
./bin/mise run completions:zsh # Generate zsh completions
93+
./bin/mise run completions:fish # Generate fish completions
94+
./bin/mise run docs:cli-reference # Generate CLI reference docs
95+
9096
# Run CLI
9197
.build/debug/exfig --help
9298
.build/debug/exfig colors -i exfig.pkl
@@ -279,6 +285,8 @@ Changing `load()` return type affects:
279285

280286
See `ExFigCLI/CLAUDE.md` (Adding a New Subcommand).
281287

288+
**Important:** When adding/changing CLI flags or subcommands, update `exfig.usage.kdl` (Usage spec) to keep shell completions and docs in sync. When bumping the app version in `ExFigCommand.swift`, also update the `version` field in `exfig.usage.kdl`.
289+
282290
### Adding a Figma API Endpoint
283291

284292
See `FigmaAPI/CLAUDE.md`.

0 commit comments

Comments
 (0)