Skip to content

Feature Request: Introduce cli.py and Move All CLI Logic Out of Modules #12

@vvillatte

Description

@vvillatte

The current bulk photo utility mixes command‑line interface (CLI) logic directly inside functional modules such as:

  • bulk_photo_renamer.py
  • bulk_photo_mover.py
  • bulk_photo_processor.py

Each of these files contains its own main() function, argument parsing, and interactive prompts. This creates duplication, makes the code harder to test, and breaks separation of concerns.

This issue proposes introducing a dedicated cli.py module that becomes the single entry point for all CLI interactions. All existing modules should be converted into pure library modules with no CLI parsing.


🎯 Goals

  • Centralise all CLI parsing and interactive input handling in a new cli.py.
  • Ensure all modules (renamer, mover, processor) expose clean functions only.
  • Improve maintainability, testability, and consistency across the project.
  • Prepare the project for packaging (e.g., pip install bulk-photo-tools) with a single console entry point.

📐 Proposed Changes

1. Create a new cli.py

Responsibilities:

  • Parse CLI arguments (source, target, flags).
  • Support test mode and verbose mode.
  • Support config file loading (via config_loader).
  • Support interactive fallback when no arguments are provided.
  • Call process_photos() from bulk_photo_processor.

2. Remove CLI logic from existing modules

Specifically:

  • Delete main() functions from:
    • bulk_photo_renamer.py
    • bulk_photo_mover.py
    • bulk_photo_processor.py
  • Remove any sys.argv parsing or interactive prompts.
  • Ensure modules expose clean functions only:
    • rename_photos()
    • move_photos()
    • process_photos()

3. Update __main__.py

  • Replace current logic with a simple import of cli.main().

4. Update pyproject.toml

  • Add a single console script entry point:
    [project.scripts]
    bulk-photo = "utility_scripts.cli:main"

5. Ensure backward compatibility

  • Running the tool via:
    python -m utility_scripts
    
    should still work.

🧪 Testing Requirements

  • Running with full CLI arguments should trigger renamer + mover.
  • Running with --test should simulate operations without modifying files.
  • Running with no arguments should fall back to interactive mode.
  • Config file loading should still work.
  • All modules should be importable without side effects.

📎 Additional Notes

This refactor will significantly improve the architecture and make future enhancements (e.g., subcommands, dry-run previews, logging improvements) much easier.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions