diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-06 21:59:40 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-06 21:59:40 -0500 |
| commit | 01cc47f067da15b3c87efc61c7b4eb97eb79d7d4 (patch) | |
| tree | 31110dd17500e0b77faf004d729521e73217de38 | |
| parent | e1912c27c08165e996c3d3a595d169de929e24b7 (diff) | |
| download | rulesets-01cc47f067da15b3c87efc61c7b4eb97eb79d7d4.tar.gz rulesets-01cc47f067da15b3c87efc61c7b4eb97eb79d7d4.zip | |
feat(make): fzf-pick LANG when not set, mirror project picker
Add a pick_lang_shell macro that fzf-picks from $(LANGUAGES) when LANG isn't set, mirroring pick_project_shell. Wire it into install-lang and diff so both vars are now optional. Blank $(LANG) when its origin is environment, since LANG is the standard POSIX locale env var and Make would otherwise inherit "en_US.UTF-8" and bypass the picker.
| -rw-r--r-- | Makefile | 37 |
1 files changed, 29 insertions, 8 deletions
@@ -15,6 +15,14 @@ DEFAULT_HOOKS := $(filter-out $(OPTIN_HOOKS),$(HOOKS)) CLAUDE_CONFIG := $(wildcard .claude/*.json) $(wildcard .claude/.*.json) LANGUAGES := $(notdir $(wildcard languages/*)) +# LANG is also the standard POSIX locale env var. Make inherits env vars into +# its variable namespace, so $(LANG) would silently expand to "en_US.UTF-8" (or +# similar) and bypass the lang picker. Blank it unless set on the command line +# or in this file. +ifeq ($(origin LANG),environment) +LANG := +endif + # Pick target project — use PROJECT= or interactive fzf over local .git dirs. # Defined inline in each recipe (not via $(shell)) so fzf only runs when needed. define pick_project_shell @@ -31,6 +39,19 @@ define pick_project_shell fi endef +# Pick language bundle — use LANG= or interactive fzf over languages/. +define pick_lang_shell + L="$(LANG)"; \ + if [ -z "$$L" ]; then \ + if ! command -v fzf >/dev/null 2>&1; then \ + echo "ERROR: LANG=<language> not set and fzf is not installed" >&2; \ + exit 1; \ + fi; \ + L=$$(printf '%s\n' $(LANGUAGES) | fzf --prompt="Language> " 2>/dev/null); \ + test -n "$$L" || { echo "No language selected." >&2; exit 1; }; \ + fi +endef + # Cross-platform package install helper (brew/apt/pacman) define install_pkg $(if $(shell command -v brew 2>/dev/null),brew install $(1),\ @@ -305,10 +326,10 @@ list-languages: ## List available language bundles @echo "Available language rulesets (languages/):" @for lang in $(LANGUAGES); do echo " - $$lang"; done -install-lang: ## Install language ruleset (LANG=<lang> [PROJECT=<path>] [FORCE=1]) - @test -n "$(LANG)" || { echo "ERROR: set LANG=<language>"; exit 1; } - @$(pick_project_shell); \ - bash scripts/install-lang.sh "$(LANG)" "$$P" "$(FORCE)" +install-lang: ## Install language ruleset ([LANG=<lang>] [PROJECT=<path>] [FORCE=1]) + @$(pick_lang_shell); \ + $(pick_project_shell); \ + bash scripts/install-lang.sh "$$L" "$$P" "$(FORCE)" install-elisp: ## Install Elisp bundle ([PROJECT=<path>] [FORCE=1]) @$(MAKE) install-lang LANG=elisp PROJECT="$(PROJECT)" FORCE="$(FORCE)" @@ -318,10 +339,10 @@ install-python: ## Install Python bundle ([PROJECT=<path>] [FORCE=1]) ##@ Compare & validate -diff: ## Show drift between installed ruleset and repo source (LANG=<lang> [PROJECT=<path>]) - @test -n "$(LANG)" || { echo "ERROR: set LANG=<language>"; exit 1; } - @$(pick_project_shell); \ - bash scripts/diff-lang.sh "$(LANG)" "$$P" +diff: ## Show drift between installed ruleset and repo source ([LANG=<lang>] [PROJECT=<path>]) + @$(pick_lang_shell); \ + $(pick_project_shell); \ + bash scripts/diff-lang.sh "$$L" "$$P" lint: ## Validate ruleset structure (headings, Applies-to, shebangs, exec bits) @bash scripts/lint.sh |
