Add command-line arguments to the executable (0.8.0) #175

Merged
ValleyGeek merged 4 commits from 0.7.2/cli-arguments into main 2026-08-23 02:33:56 +00:00
Member

Summary

  • Adds a real CLI to the compiled executable / python -m bulk_image_organizer entry point: a positional DIRECTORY to open and scan on startup, --version, --help, --theme light|dark (one-run override), --no-auto-scan, --no-restore-session, --log-level, --debug, and --config-dir/--portable to relocate the global settings database.
  • Fixes --help/--version output not appearing on Windows: switches --windows-console-mode from disable to attach, and explicitly rebinds sys.stdout/sys.stderr/sys.stdin to the attached console via ctypes (Nuitka's attach mode alone doesn't rebind CPython's own stdio streams — confirmed against a real Windows build). A normal double-click launch stays console-free.
  • Documents the new options in resources/help/USER_GUIDE.md and README.md.
  • Decision records: DR-042, DR-043 in docs/DECISIONS.md.
  • Version bump: 0.7.2 → 0.8.0 (minor/feature segment).

Test plan

  • ruff check . / ruff format --check .
  • pytest — 714 passed, 1 skipped
  • Offscreen smoke run of --help, --version, --config-dir, --theme, --no-auto-scan, --no-restore-session, --debug, and a positional directory scan (Linux, QT_QPA_PLATFORM=offscreen)
  • User-confirmed on a real Windows build (dev-0.7.2-cli-arguments): --help/--version now print correctly when run from an existing PowerShell/cmd window; double-click launch still shows no console window

🤖 Generated with Claude Code

https://claude.ai/code/session_01DzefUecUsnBymyMs8XFQrM

## Summary - Adds a real CLI to the compiled executable / `python -m bulk_image_organizer` entry point: a positional `DIRECTORY` to open and scan on startup, `--version`, `--help`, `--theme light|dark` (one-run override), `--no-auto-scan`, `--no-restore-session`, `--log-level`, `--debug`, and `--config-dir`/`--portable` to relocate the global settings database. - Fixes `--help`/`--version` output not appearing on Windows: switches `--windows-console-mode` from `disable` to `attach`, and explicitly rebinds `sys.stdout`/`sys.stderr`/`sys.stdin` to the attached console via `ctypes` (Nuitka's `attach` mode alone doesn't rebind CPython's own stdio streams — confirmed against a real Windows build). A normal double-click launch stays console-free. - Documents the new options in `resources/help/USER_GUIDE.md` and `README.md`. - Decision records: DR-042, DR-043 in `docs/DECISIONS.md`. - Version bump: 0.7.2 → 0.8.0 (minor/feature segment). ## Test plan - [x] `ruff check .` / `ruff format --check .` - [x] `pytest` — 714 passed, 1 skipped - [x] Offscreen smoke run of `--help`, `--version`, `--config-dir`, `--theme`, `--no-auto-scan`, `--no-restore-session`, `--debug`, and a positional directory scan (Linux, `QT_QPA_PLATFORM=offscreen`) - [x] User-confirmed on a real Windows build (`dev-0.7.2-cli-arguments`): `--help`/`--version` now print correctly when run from an existing PowerShell/cmd window; double-click launch still shows no console window 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DzefUecUsnBymyMs8XFQrM
feat(cli): add command-line parameters to the executable
All checks were successful
CI / lint (push) Successful in 17s
CI / test (push) Successful in 3m6s
CI / appimage (push) Successful in 17m13s
CI / build-appimage (push) Successful in 0s
CI / windows-exe (push) Successful in 19m10s
CI / build-windows-exe (push) Successful in 0s
e3abaa979d
Adds a real CLI to main.py's compiled entry point (shared with
`python -m bulk_image_organizer` via a new cli_main() wrapper):
positional `directory` to open and scan on startup, --version/--help,
--theme (light|dark, one-run override), --no-auto-scan,
--no-restore-session, --log-level/--debug, and --config-dir/--portable
to relocate the global config database. Unrecognized args (Qt's own
-style/-platform/etc.) are still forwarded to QApplication untouched.

MainWindow gains an optional global_config_db_path constructor param
so --config-dir/--portable actually reach the GlobalConfigDB instance
the running window uses, not just the one built in main().

Threading notes: no worker/threading changes; all new logic runs on
the main thread before/around QApplication construction.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DzefUecUsnBymyMs8XFQrM
fix(packaging): attach to console on Windows so CLI output is visible
All checks were successful
CI / lint (push) Successful in 17s
CI / test (push) Successful in 2m57s
CI / appimage (push) Successful in 18m16s
CI / build-appimage (push) Successful in 0s
CI / windows-exe (push) Successful in 23m16s
CI / build-windows-exe (push) Successful in 0s
5853424d1a
--help/--version/--bio-packaging-self-test printed nothing on a
Windows build because release builds pass
--windows-console-mode=disable (DR-016), which detaches stdio
unconditionally -- even when the exe is launched from an existing
terminal. Switch to --windows-console-mode=attach in main.py's
nuitka-project header and scripts/manual-build-windows.ps1 (which
does not read those comments and needs its own copy): a double-click
GUI launch still gets no console window, but running the exe from
cmd/PowerShell now attaches to that console so argparse's output is
visible. Recorded as DR-042 (supersedes the console-mode value picked
in DR-016, not its single-file-distribution goal). Updated a stale
logging_config.py docstring that assumed console mode was always
"disable".

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DzefUecUsnBymyMs8XFQrM
fix(packaging): explicitly rebind stdio to the attached console on Windows
All checks were successful
CI / lint (push) Successful in 16s
CI / test (push) Successful in 3m3s
CI / windows-exe (push) Successful in 15m52s
CI / build-windows-exe (push) Successful in 0s
CI / appimage (push) Successful in 16m20s
CI / build-appimage (push) Successful in 0s
99855df673
DR-042's --windows-console-mode=attach alone was confirmed insufficient
on a real Windows build (dev-0.7.2-cli-arguments): the user ran --help
and --version from an already-open PowerShell window and got no output.
A GUI-subsystem process's sys.stdout/sys.stderr are bound once at
process startup, before Nuitka's attach logic runs -- attaching a
console afterward doesn't retroactively fix file objects that were
already invalid when created.

Add _attach_windows_console(), called first in cli_main() before
argparse runs: calls kernel32.AttachConsole(-1), treats
ERROR_ACCESS_DENIED (already has a console) as success too, then
reopens sys.stdout/sys.stderr against CONOUT$ and sys.stdin against
CONIN$. No-op on non-Windows and a safe no-op when there's truly no
parent console (a double-click launch stays console-free). Recorded
as DR-043 (supersedes DR-042's status, not its --windows-console-mode
value).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DzefUecUsnBymyMs8XFQrM
docs: PR-prep for command-line arguments (0.8.0)
Some checks failed
CI / lint (push) Successful in 18s
CI / test (push) Successful in 3m3s
CI / appimage (push) Failing after 10s
CI / build-appimage (push) Failing after 0s
CI / windows-exe (push) Successful in 19m28s
CI / build-windows-exe (push) Successful in 0s
023b6c05e8
Documents the new CLI (positional directory, --version, --help,
--theme, --no-auto-scan, --no-restore-session, --log-level, --debug,
--config-dir/--portable) in the bundled USER_GUIDE.md and README.md,
including the Windows console-attach caveat for --help/--version.
Bumps VERSION 0.7.2 -> 0.8.0 (minor/feature segment, compiled inputs
changed on this branch) and adds the CHANGELOG.md entry.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DzefUecUsnBymyMs8XFQrM
ValleyGeek deleted branch 0.7.2/cli-arguments 2026-08-23 02:33:57 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ai-collab/bulk-image-organizer!175
No description provided.