Skip to content

Standardize CLI exit codes #25

Description

@KHolodilin

Description

Implement standardized exit codes for the CLI to provide clear error reporting and better integration with scripts and automation tools. Define and document exit codes for different error scenarios to improve user experience and enable proper error handling in automated workflows.

Implemented in PR #26 (branch feature/issue-5-standardize-exit-codes). Exit codes are defined in email_processor.exit_codes.ExitCode (IntEnum).

Tasks

  • Define exit code constants
    • Module email_processor/exit_codes.py with enum ExitCode:
      • SUCCESS = 0, PROCESSING_ERROR = 1, VALIDATION_FAILED = 2, FILE_NOT_FOUND = 3, UNSUPPORTED_FORMAT = 4, WARNINGS_AS_ERRORS = 5, CONFIG_ERROR = 6
  • Update CLI code to use standardized exit codes
    • CLI commands (config, imap, passwords, smtp, status) and __main__ return ExitCode values
    • Mapping: processing → 1, validation → 2, file not found → 3, unsupported format → 4, warnings as errors → 5, config → 6
  • Add exit codes documentation to README
    • "Exit Codes" section with table, bash/Python examples, common scenarios; key features updated
  • Add tests for exit codes
    • Unit and integration tests updated for new codes; correctness verified

Standard Exit Codes

Code Constant Description
0 SUCCESS Operation completed successfully
1 PROCESSING_ERROR Errors during extraction, parsing, mapping, or write operations
2 VALIDATION_FAILED Input validation errors (e.g., invalid arguments, email format)
3 FILE_NOT_FOUND Requested file or directory does not exist
4 UNSUPPORTED_FORMAT Cannot detect or process the requested format (e.g., authentication/keyring)
5 WARNINGS_AS_ERRORS Warnings treated as errors (--fail-on-warnings enabled)
6 CONFIG_ERROR Errors loading or validating configuration file

Acceptance Criteria

  • All tests pass
  • Pre-commit checks pass
  • Exit codes standardized across all CLI commands
  • Exit codes documentation added to README
  • Tests for exit codes added/updated
  • Code committed
  • Branch pushed to remote repository
  • Pull Request created (PR #26)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions