Skip to content

feat(cli): support APFEL_DEBUG env var for debug logging (#164)#165

Closed
Arthur-Ficial wants to merge 1 commit into
mainfrom
fix/issue-164-apfel-debug-env
Closed

feat(cli): support APFEL_DEBUG env var for debug logging (#164)#165
Arthur-Ficial wants to merge 1 commit into
mainfrom
fix/issue-164-apfel-debug-env

Conversation

@Arthur-Ficial
Copy link
Copy Markdown
Owner

Draft PR - needs @franzenzenhofer review and local test run before merging.

Fixes #164.

Root cause

apfel supports a full family of APFEL_* environment variables (APFEL_PORT, APFEL_TOKEN, APFEL_SYSTEM_PROMPT, etc.) but --debug was only available as a CLI flag. Users who always want debug output - e.g. when integrating apfel into pipelines or tools like MacParakeet - had to pass --debug on every invocation. A APFEL_DEBUG env var was the missing piece.

The fix

Added APFEL_DEBUG environment variable support in CLIArguments.parse(), following the exact same pattern as the other APFEL_* env vars. When APFEL_DEBUG is set to any non-empty value (e.g. 1, true, yes), debug logging is enabled. Empty string is treated as unset. The --debug CLI flag still works and takes precedence (CLI flags are parsed after env defaults, matching existing behaviour).

Also added APFEL_DEBUG to the help text's ENVIRONMENT section.

Test coverage

  • Added CLIArgumentsTests: "APFEL_DEBUG env enables debug" - basic APFEL_DEBUG=1 case
  • Added CLIArgumentsTests: "APFEL_DEBUG env with any non-empty value enables debug" - APFEL_DEBUG=true
  • Added CLIArgumentsTests: "APFEL_DEBUG env empty string does not enable debug" - empty string guard
  • Added CLIArgumentsTests: "--debug CLI flag works without APFEL_DEBUG env" - confirms existing flag still works
  • Existing --debug sets debug test at line 268 covers the original flag path

What I verified (static only)

  • Diff is 3 files, 24 lines added, zero lines removed
  • Follows the identical env var pattern used by every other APFEL_* variable in CLIArguments.parse()
  • --debug CLI flag (line 306) runs after env defaults (line 191), so CLI always wins - same precedence as --port vs APFEL_PORT
  • No new dependencies, no changes to Package.swift
  • No touches to .version, BuildInfo.swift, release scripts, CI workflows, or guardrail files
  • Swift 6 concurrency: no new shared mutable state - debug is a plain Bool on a Sendable struct, written once during parsing

What I did NOT verify

  • Functional correctness. This needs make test on a Mac with Apple Intelligence. I cannot run FoundationModels code. If the fix does not actually resolve the reported behaviour, that is on me to refine - ping me in a review comment.

Anything that seemed suspicious

Nothing - straightforward enhancement request from a legitimate user with a clear use case (MacParakeet dictation cleanup).


cc @franzenzenhofer - draft stays draft until you review, test locally, and mark ready.

Generated by the apfel bug-solver routine.


Generated by Claude Code

Users who always want debug output (e.g. when piping through other tools)
had to pass --debug on every invocation. APFEL_DEBUG=1 (or any non-empty
value) now enables debug logging via the environment, consistent with the
existing APFEL_* env var family. CLI --debug flag still works and takes
precedence.

Drafted by the apfel bug-solver routine. Needs review + local test run
by @franzenzenhofer on a Mac with Apple Intelligence before merging.
@Arthur-Ficial
Copy link
Copy Markdown
Owner Author

Superseded by the v1.5.0 release, which implements APFEL_DEBUG (issue #164) on main with tests and docs: https://github.com/Arthur-Ficial/apfel/releases/tag/v1.5.0. Closing this duplicate.

@Arthur-Ficial Arthur-Ficial deleted the fix/issue-164-apfel-debug-env branch June 1, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for debug logging

2 participants