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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
//! Centralized message management system for kasl application.
//!
//! Provides a comprehensive message handling infrastructure that serves as the
//! foundation for all user communication in the kasl application.
//!
//! ## Features
//!
//! - **Type Safety**: All messages are compile-time verified with proper parameters
//! - **Centralization**: Single source of truth for all user-facing text
//! - **Consistency**: Uniform formatting and presentation across the application
//! - **Extensibility**: Easy addition of new message types and categories
//! - **Internationalization**: Structure supports future localization efforts
//!
//! ## Usage
//!
//! ```rust
//! use kasl::libs::messages::{Message, success, error};
//! use kasl::{msg_info, msg_error, msg_success};
//!
//! msg_success!(Message::TaskCreated);
//! msg_error!(Message::ConfigSaveError);
//! msg_info!(Message::MonitorStarted {
//! pause_threshold: 60,
//! poll_interval: 500,
//! activity_threshold: 30,
//! });
//! ```
// Re-export the main Message type for convenient access
pub use Message;
/// Creates a success message with a green checkmark prefix.
///
/// This function provides a standardized way to format success messages
/// throughout the application. It ensures consistent visual presentation
/// for positive feedback and completion notifications.
///
/// ## Visual Format
///
/// Success messages are prefixed with a green checkmark (â
) to provide
/// immediate visual feedback about successful operations. This creates
/// a consistent user experience across all success scenarios.
///
/// ## Usage Context
///
/// This function is typically used for:
/// - Operation completion confirmations
/// - Successful data saves or updates
/// - Configuration changes applied successfully
/// - External API communication success
/// - File operations completed without errors
///
/// # Arguments
///
/// * `msg` - A [`Message`] enum variant containing the success details
///
/// # Returns
///
/// Returns a formatted string with the success prefix and message text.
///
/// # Examples
///
/// ```rust
/// use kasl::libs::messages::{Message, success};
///
/// // Format a simple success message
/// let message = success(Message::TaskCreated);
/// println!("{}", message); // "â
Task created successfully"
///
/// // With parameters
/// let report_message = success(Message::DailyReportSent("2025-01-15".to_string()));
/// println!("{}", report_message); // "â
Your report dated 2025-01-15 has been successfully submitted..."
/// ```
///
/// # Integration with Macros
///
/// This function works seamlessly with the application's messaging macros:
/// ```rust
/// use kasl::msg_success;
/// use kasl::libs::messages::Message;
///
/// // Equivalent to using success() function directly
/// msg_success!(Message::TaskCreated);
/// ```
/// Creates an error message with a red X prefix.
///
/// This function provides a standardized way to format error messages
/// throughout the application. It ensures consistent visual presentation
/// for error conditions and failure notifications, helping users quickly
/// identify and understand problems.
///
/// ## Visual Format
///
/// Error messages are prefixed with a red X (â) to provide immediate
/// visual indication of error conditions. This creates a consistent
/// user experience for error reporting across all application areas.
///
/// ## Error Message Philosophy
///
/// Error messages created by this function follow these principles:
/// - **Clear Problem Description**: Explain what went wrong
/// - **Helpful Context**: Provide relevant details for troubleshooting
/// - **Action Guidance**: Suggest next steps when possible
/// - **Non-Technical Language**: Avoid intimidating technical jargon
///
/// ## Usage Context
///
/// This function is typically used for:
/// - Operation failures and exceptions
/// - Validation errors and invalid input
/// - Configuration problems and conflicts
/// - External service communication failures
/// - File system and permission errors
///
/// # Arguments
///
/// * `msg` - A [`Message`] enum variant containing the error details
///
/// # Returns
///
/// Returns a formatted string with the error prefix and message text.
///
/// # Examples
///
/// ```rust
/// use kasl::libs::messages::{Message, error};
///
/// // Format a simple error message
/// let message = error(Message::ConfigSaveError);
/// println!("{}", message); // "â Failed to save configuration"
///
/// // With error details
/// let detailed_error = error(Message::GitlabFetchFailed("Network timeout".to_string()));
/// println!("{}", detailed_error); // "â [kasl] Failed to get GitLab events: Network timeout"
/// ```
///
/// # Error Handling Integration
///
/// This function integrates with the application's error handling:
/// ```rust
/// use kasl::msg_error;
/// use kasl::libs::messages::Message;
/// use anyhow::Result;
///
/// # fn operation() -> Result<()> { Ok(()) }
/// fn save_config() -> Result<()> {
/// // ... operation that might fail
/// if let Err(_) = operation() {
/// msg_error!(Message::ConfigSaveError);
/// return Err(anyhow::anyhow!("Configuration save failed"));
/// }
/// Ok(())
/// }
/// ```
/// Creates a warning message with a yellow warning triangle prefix.
///
/// This function provides a standardized way to format warning messages
/// throughout the application. Warnings indicate situations that require
/// user attention but are not necessarily errors or failures.
///
/// ## Visual Format
///
/// Warning messages are prefixed with a yellow warning triangle (â ī¸) to
/// indicate important information that users should be aware of. This
/// provides a visual middle ground between informational and error messages.
///
/// ## Warning Message Types
///
/// Warnings are appropriate for these scenarios:
/// - **Deprecation Notices**: Features that will be removed in future versions
/// - **Configuration Issues**: Non-critical configuration problems
/// - **Data Quality**: Potential issues with user data or inputs
/// - **Performance Notices**: Operations that might be slow or resource-intensive
/// - **Compatibility Warnings**: Version or platform compatibility concerns
///
/// ## Usage Context
///
/// This function is typically used for:
/// - Non-critical configuration issues
/// - Deprecated feature usage notifications
/// - Data quality concerns or anomalies
/// - Performance or resource usage warnings
/// - Compatibility or version mismatch notices
///
/// # Arguments
///
/// * `msg` - A [`Message`] enum variant containing the warning details
///
/// # Returns
///
/// Returns a formatted string with the warning prefix and message text.
///
/// # Examples
///
/// ```rust
/// use kasl::libs::messages::{Message, warning};
///
/// // Format a configuration warning
/// let message = warning(Message::AutostartRequiresAdmin);
/// println!("{}", message); // "â ī¸ Administrator privileges required for system-level autostart."
///
/// // Data quality warning
/// let data_warning = warning(Message::ShortIntervalsDetected(3, "45 minutes".to_string()));
/// println!("{}", data_warning); // "â ī¸ Detected 3 short intervals totaling 45 minutes"
/// ```
///
/// # Integration with Application Flow
///
/// Warnings often provide guidance for resolution:
/// ```rust
/// use kasl::msg_warning;
/// use kasl::libs::messages::Message;
///
/// // Warning with follow-up guidance
/// let count = 3;
/// let duration = "45 minutes".to_string();
/// msg_warning!(Message::ShortIntervalsDetected(count, duration));
/// ```
/// Creates an informational message with a blue info icon prefix.
///
/// This function provides a standardized way to format informational messages
/// throughout the application. Info messages convey status updates, progress
/// notifications, and general information that helps users understand what
/// the application is doing.
///
/// ## Visual Format
///
/// Informational messages are prefixed with a blue info icon (âšī¸) to indicate
/// general status information that is helpful but not critical. This provides
/// clear visual categorization for different types of user feedback.
///
/// ## Information Message Types
///
/// Info messages are appropriate for these scenarios:
/// - **Status Updates**: Current operation progress and status
/// - **Configuration Information**: Details about current settings
/// - **Process Notifications**: Background process status and lifecycle
/// - **Data Statistics**: Summaries and counts of application data
/// - **Help and Guidance**: Instructional content and next steps
///
/// ## Usage Context
///
/// This function is typically used for:
/// - Background process status updates
/// - Operation progress notifications
/// - Configuration and setup information
/// - Data summary and statistics display
/// - General user guidance and tips
///
/// # Arguments
///
/// * `msg` - A [`Message`] enum variant containing the informational content
///
/// # Returns
///
/// Returns a formatted string with the info prefix and message text.
///
/// # Examples
///
/// ```rust
/// use kasl::libs::messages::{Message, info};
///
/// // Format a status update
/// let message = info(Message::MonitorStarted {
/// pause_threshold: 60,
/// poll_interval: 500,
/// activity_threshold: 30,
/// });
/// println!("{}", message); // "âšī¸ Monitor is running with pause threshold 60s, poll interval 500ms, activity threshold 30s"
///
/// // Configuration information
/// let config_info = info(Message::AutostartStatus("enabled".to_string()));
/// println!("{}", config_info); // "âšī¸ Autostart is currently: enabled"
/// ```
///
/// # Complementary Usage
///
/// Info messages often work together with other message types:
/// ```rust
/// use kasl::{msg_info, msg_success};
/// use kasl::libs::messages::Message;
///
/// // Sequential information flow
/// msg_info!(Message::WatcherStartingForeground);
/// // ... operation occurs
/// msg_success!(Message::WatcherStarted(12345));
/// ```
/// Wraps a message with newlines for emphasis and visual separation.
///
/// This function provides enhanced visual formatting for messages that require
/// special emphasis or clear separation from surrounding content. It adds
/// newlines before and after the message text to create visual whitespace
/// that draws attention to important information.
///
/// ## Visual Format
///
/// Wrapped messages are formatted with newlines on both sides:
/// ```text
///
/// Your important message here
///
/// ```
///
/// This creates clear visual separation from other content and emphasizes
/// the importance of the message.
///
/// ## Usage Context
///
/// Message wrapping is appropriate for:
/// - **Critical Announcements**: Important system notifications
/// - **Section Headers**: Major section dividers in output
/// - **Final Results**: Summary information at the end of operations
/// - **Error Emphasis**: Critical errors that require immediate attention
/// - **Interactive Prompts**: Important questions or confirmations
///
/// ## Design Considerations
///
/// Wrapped messages should be used sparingly to maintain their emphasis
/// effect. Overuse can clutter the interface and reduce the impact of
/// truly important messages.
///
/// # Arguments
///
/// * `msg` - A [`Message`] enum variant to be wrapped with emphasis
///
/// # Returns
///
/// Returns a formatted string with newlines before and after the message text.
///
/// # Examples
///
/// ```rust
/// use kasl::libs::messages::{Message, wrap_msg};
///
/// // Emphasize a critical message
/// let message = wrap_msg(Message::ConfirmDeleteAllTodayTasksFinal);
/// println!("{}", message);
/// // Output:
/// //
/// // This action cannot be undone. Continue?
/// //
///
/// // Wrap a summary message
/// let summary = wrap_msg(Message::AllMigrationsCompleted);
/// println!("{}", summary);
/// // Output:
/// //
/// // All migrations completed successfully
/// //
/// ```
///
/// # Integration with Other Formatting
///
/// Wrapped messages can be combined with prefix functions:
/// ```rust
/// use kasl::libs::messages::{Message, success, wrap_msg};
///
/// // Create an emphasized success message using the prefix function directly
/// let emphasized_success = format!("\n{}\n", success(Message::OperationCompleted));
/// // Or use wrap_msg directly on the Message for consistent formatting
/// let wrapped_success = wrap_msg(Message::OperationCompleted);
/// ```