Skip to content

fix(cli): add --version flag, version command, and make progress spinner TTY-aware (#119) - #127

Closed
dianatofficial wants to merge 1 commit into
secfoo-com:mainfrom
dianatofficial:fix/cli-version-spinner-duplication-119
Closed

dianatofficial wants to merge 1 commit into
secfoo-com:mainfrom
dianatofficial:fix/cli-version-spinner-duplication-119

Conversation

@dianatofficial

Copy link
Copy Markdown

Summary

Addresses all three CLI defects reported in #119:

  1. Version flag & command:

    • Added eager --version / -v option to the root Typer callback (secfoo --version and secfoo -v).
    • Added secfoo version command and secfoo version --json outputting structured environment details (version, python, platform, store_path, config_path).
    • Documented --version and version --json in docs/REFERENCE.md.
  2. TTY-aware progress spinner:

    • Introduced _is_stdout_tty() to detect whether stdout is an actual terminal, regardless of FORCE_COLOR setting.
    • When stdout is not a TTY (file redirection, pipeline, CI capture), the animated Progress spinner is disabled, preventing tens of kilobytes of cursor redraw escape frames (\x1b[2K, \x1b[1A, \x1b[?25) from flooding captured logs.
  3. Deduplicated completion lines:

    • In non-TTY mode, emits exactly one line on skill start and one line on skill completion directly to the console.
    • Prevents the double completion output caused by the live progress display's final refresh on task stop.
    • In --json mode, retains pure byte-exact JSON on stdout without progress lines.

Verification

  • Added comprehensive unit tests in tests/test_cli.py:
    • test_version_flag: asserts secfoo --version and -v exit 0 with version text.
    • test_version_command: asserts secfoo version output.
    • test_version_command_json: parses and validates all JSON keys (version, python, platform, store_path, config_path).
    • test_non_tty_run_no_spinner_flooding_and_no_duplicate_completion: asserts no cursor-movement escapes under FORCE_COLOR=1, compact byte count (<2.5 KB), and single occurrence of start/completion lines.
    • test_json_run_suppresses_progress_lines: asserts byte-exact JSON document parsing.
  • Verified all 68 tests in tests/test_cli.py pass cleanly.
  • Code style and import sorting verified with ruff.

Fixes #119

@vsn411

vsn411 commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Closing this without merging. #126 already landed the fix for #119 on main (6795c976), and this branch conflicts with that merge.

A few differences worth keeping in mind:

  • --version is printed with console.print, so a FORCE_COLOR=1 CI job can get a highlighted version string. The merged fix uses typer.echo, which stays plain secfoo <version>. The short flag here is -v; main uses -V.
  • secfoo version without --json prints only the version. On main it also prints Python, platform, store path, and config path.
  • Non-TTY progress lines still go through Rich markup ([bold], status style), so captured logs can still contain color codes when FORCE_COLOR is set. isatty() does stop the spinner flood.
  • The new tests hardcode 0.3.0 instead of reading __version__. The non-TTY test does not pass --agent, so it depends on _detect_agent() picking Claude. CliRunner strips ANSI unless color=True, so the \x1b[2K / \x1b[1A / \x1b[?25 assertions do not see spinner frames.

#119 stays open.

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.

CLI bugs: no --version, spinner floods non-TTY logs when FORCE_COLOR is set, completion lines printed twice

2 participants