Skip to content

Implement CLI Entry Point with Comprehensive Argument Parsing#12

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-1
Draft

Implement CLI Entry Point with Comprehensive Argument Parsing#12
Copilot wants to merge 3 commits intomainfrom
copilot/fix-1

Conversation

Copy link

Copilot AI commented Sep 14, 2025

This PR implements a complete command-line interface for the PhotoSort application as specified in issue #1. The CLI provides a user-friendly interface for organizing photos and videos by date and location using metadata.

Key Features Implemented

CLI Commands:

  • photosort /path/to/photos - Default organize command
  • photosort /path/to/photos --scan - Generate scan report
  • photosort /path/to/photos --command organize --dry-run - Preview changes without moving files

Command Line Options:

  • --command {scan,organize} or -c - Specify operation mode (default: organize)
  • --scan - Shorthand for scan command
  • --output DIR or -o - Custom output directory (default: input_path/sorted)
  • --dry-run or -n - Preview mode without file operations
  • --report-file FILE or -r - Custom scan report location
  • --log-file FILE or -l - Custom operation log location
  • --verbose or -v - Enable detailed output

Error Handling:

  • Input path validation (existence and directory check)
  • Output path validation for organize operations
  • Graceful keyboard interrupt handling (Ctrl+C)
  • Proper exit codes for different error conditions
  • User-friendly error messages

Implementation Details

The CLI is built using Python's argparse module with:

  • Comprehensive argument validation
  • Default value assignment for optional parameters
  • Type hints and proper documentation
  • Modular design ready for integration with core modules

The implementation includes placeholder functions run_scan_command() and run_organize_command() that are ready to be connected to the scanner and organizer modules once they are implemented.

Testing

Added comprehensive test coverage with 27 unit tests covering:

  • Argument parsing for all options and commands
  • Input validation scenarios
  • Error handling and edge cases
  • Help text and usage scenarios
  • Main function integration testing

Test Results:

  • 99% code coverage
  • All tests passing
  • Pylint score: 10/10
  • Type checking with mypy: no issues

Usage Examples

# Scan photos and generate report
poetry run python -m photosort.main /path/to/photos --scan

# Organize photos (default behavior)
poetry run python -m photosort.main /path/to/photos

# Preview organization without moving files
poetry run python -m photosort.main /path/to/photos --dry-run

# Organize with custom output directory
poetry run python -m photosort.main /path/to/photos --output /organized/photos

# Get help
poetry run python -m photosort.main --help

The CLI is now ready to be integrated with the core PhotoSort functionality for metadata extraction, file scanning, and photo organization.

Fixes #1.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • install.python-poetry.org
    • Triggering command: curl -sSL REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits September 14, 2025 14:00
Co-authored-by: fedem-p <56798675+fedem-p@users.noreply.github.com>
Co-authored-by: fedem-p <56798675+fedem-p@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement CLI Entry Point Implement CLI Entry Point with Comprehensive Argument Parsing Sep 14, 2025
Copilot AI requested a review from fedem-p September 14, 2025 14:06
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.

Implement CLI Entry Point

2 participants