diff options
Diffstat (limited to 'Makefile')
| -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 |
