Added
- Comprehensive error handling system with custom exception classes:
- `JsonFormatError` as base exception
- `FileAccessError` for file-related issues
- `JsonParseError` for JSON parsing problems
- Type hints for better code clarity and IDE support
- Detailed docstrings for all functions following standard Python format
- Path validation using `pathlib`
- UTF-8 encoding support for file operations
- Proper error messages directed to stderr
- System exit codes (0 for success, 1 for error)
- New utility functions for better code organization:
- `read_file()` for safe file reading
- `validate_file_path()` for path validation
- `process_json_file()` for high-level processing
- Explicit `--no-sort` flag to disable JSON key sorting
Changed
- Migrated from Click to Argparse for command-line argument parsing
- Restructured command-line interface while maintaining the same functionality
- Updated help messages and argument descriptions for better clarity
- Improved error message formatting
- Enhanced file handling with better exception management
- Refactored code structure for better separation of concerns
Technical Details
- Command-line arguments now use argparse's native boolean flag handling
- Maintained backward compatibility with existing JSON formatting functionality
- Default behavior of sorting remains enabled
- Added type annotations throughout the codebase
- Implemented proper resource handling for file operations