1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//! Table formatting utilities for displaying structured CLI output.
//!
//! This module provides specialized table formatting capabilities for displaying
//! various types of structured data in the SubX CLI. It focuses primarily on
//! match operation results but can be extended for other tabular data needs.
//!
//! # Features
//!
//! - **Match Results Display**: Formatted tables for AI matching operations
//! - **Consistent Styling**: Rounded borders and aligned columns
//! - **Internationalization**: Support for Chinese column headers
//! - **Flexible Layout**: Automatic column width adjustment
//!
//! # Table Styling
//!
//! All tables use a consistent rounded border style with left-aligned content
//! for optimal readability. The styling is designed to work well in both
//! light and dark terminal themes.
//!
//! # Examples
//!
//! ```rust
//! use subx_cli::cli::table::{MatchDisplayRow, create_match_table};
//!
//! // Each match result is split into multiple lines for display: video, subtitle and new name
//! let rows = vec![
//! MatchDisplayRow {
//! file_type: "Video 1".to_string(),
//! file_path: "movie.mp4".to_string(),
//! },
//! MatchDisplayRow {
//! file_type: "Subtitle 1".to_string(),
//! file_path: "subtitle.srt".to_string(),
//! },
//! MatchDisplayRow {
//! file_type: "New name 1".to_string(),
//! file_path: "movie.srt".to_string(),
//! },
//! ];
//!
//! let table = create_match_table(rows);
//! println!("{}", table);
//! ```
use ;
use ;
/// Display row structure for file matching operation results.
///
/// This structure represents a single row in the match results table,
/// containing file type identifier and complete file path. Each row shows
/// one piece of information from an AI-powered file matching operation,
/// with multiple rows grouped together to represent one complete match result.
///
/// # Field Descriptions
///
/// - `file_type`: File type identifier (Video 1, Subtitle 1, New name 1)
/// - `file_path`: Complete file path displayed without truncation
///
/// # File Type Identifiers
///
/// Standard file type values:
/// - `Video 1`, `Video 2`, etc.: Original video files used as reference
/// - `Subtitle 1`, `Subtitle 2`, etc.: Original subtitle files to be renamed
/// - `New name 1`, `New name 2`, etc.: Generated new names for subtitle files
///
/// # Examples
///
/// ```rust
/// use subx_cli::cli::table::MatchDisplayRow;
///
/// // Video file entry
/// let video_row = MatchDisplayRow {
/// file_type: "Video 1".to_string(),
/// file_path: "/path/to/Movie.2023.1080p.BluRay.mp4".to_string(),
/// };
///
/// // Subtitle file entry
/// let subtitle_row = MatchDisplayRow {
/// file_type: "Subtitle 1".to_string(),
/// file_path: "/path/to/random_subtitle.srt".to_string(),
/// };
///
/// // New name entry
/// let newname_row = MatchDisplayRow {
/// file_type: "New name 1".to_string(),
/// file_path: "/path/to/Movie.2023.1080p.BluRay.srt".to_string(),
/// };
/// ```
/// Match result table row for displaying file type and path in clean two-column layout
/// Create a formatted table string from match operation results.
///
/// Transforms a collection of match display rows into a beautifully formatted
/// table string suitable for terminal display. The table uses consistent
/// styling with rounded borders and proper column alignment for optimal
/// readability.
///
/// # Table Features
///
/// - **Rounded borders**: Modern, visually appealing table style
/// - **Left alignment**: Consistent text alignment for all content rows
/// - **Auto-sizing**: Columns automatically adjust to content width
/// - **Header styling**: Clear distinction between headers and data
/// - **Unicode support**: Proper handling of Chinese characters and symbols
///
/// # Arguments
///
/// * `rows` - Vector of `MatchDisplayRow` structures to be displayed
///
/// # Returns
///
/// A formatted table string ready for printing to the terminal
///
/// # Examples
///
/// ```rust
/// use subx_cli::cli::table::{MatchDisplayRow, create_match_table};
///
/// // Multi-line display of multiple match results
/// let results = vec![
/// MatchDisplayRow { file_type: "Video 1".to_string(), file_path: "Movie.mp4".to_string() },
/// MatchDisplayRow { file_type: "Subtitle 1".to_string(), file_path: "sub123.srt".to_string() },
/// MatchDisplayRow { file_type: "New name 1".to_string(), file_path: "Movie.srt".to_string() },
/// MatchDisplayRow { file_type: "Video 2".to_string(), file_path: "Episode.mkv".to_string() },
/// MatchDisplayRow { file_type: "Subtitle 2".to_string(), file_path: "unknown.srt".to_string() },
/// MatchDisplayRow { file_type: "New name 2".to_string(), file_path: "Episode.srt".to_string() },
/// ];
///
/// let table = create_match_table(results);
/// println!("{}", table);
/// ```
///
/// # Output Example
///
/// ```text
/// ╭──────┬──────────────┬──────────────┬──────────────╮
/// │ Status │ Video File │ Subtitle File │ New Name │
/// ├──────┼──────────────┼──────────────┼──────────────┤
/// │ ✓ │ Movie.mp4 │ sub123.srt │ Movie.srt │
/// │ ⚠ │ Episode.mkv │ unknown.srt │ Episode.srt │
/// ╰──────┴──────────────┴──────────────┴──────────────╯
/// ```
///
/// # Empty Input Handling
///
/// If an empty vector is provided, returns a table with only headers,
/// indicating no results to display.