vkteams-bot-cli 0.7.6

High-performance VK Teams Bot API toolkit with CLI and MCP server support
Documentation
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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
//! File upload and management commands

use crate::commands::{Command, OutputFormat};
use crate::errors::prelude::{CliError, Result as CliResult};
use crate::output::{CliResponse, OutputFormatter};
use async_trait::async_trait;
use base64::Engine;
use clap::{Args, Subcommand};
use serde_json::json;
use vkteams_bot::prelude::*;

#[derive(Debug, Clone, Subcommand)]
pub enum FileCommands {
    /// Upload file from base64 content
    Upload(UploadFileArgs),
    /// Upload text content as file
    UploadText(UploadTextArgs),
    /// Upload JSON data as file
    UploadJson(UploadJsonArgs),
    /// Get file information
    Info(FileInfoArgs),
}

#[derive(Debug, Clone, Args)]
pub struct UploadFileArgs {
    /// File name with extension
    #[arg(long)]
    pub name: String,

    /// Base64 encoded file content
    #[arg(long)]
    pub content_base64: String,

    /// Optional caption/text message
    #[arg(long)]
    pub caption: Option<String>,

    /// Reply to message ID
    #[arg(long)]
    pub reply_msg_id: Option<String>,

    /// Chat ID (will use default from config if not provided)
    #[arg(long)]
    pub chat_id: Option<String>,
}

#[derive(Debug, Clone, Args)]
pub struct UploadTextArgs {
    /// File name with extension
    #[arg(long)]
    pub name: String,

    /// Text content to save as file
    #[arg(long)]
    pub content: String,

    /// Optional caption/description
    #[arg(long)]
    pub caption: Option<String>,

    /// Reply to message ID
    #[arg(long)]
    pub reply_msg_id: Option<String>,

    /// Chat ID (will use default from config if not provided)
    #[arg(long)]
    pub chat_id: Option<String>,
}

#[derive(Debug, Clone, Args)]
pub struct UploadJsonArgs {
    /// File name (will add .json extension if missing)
    #[arg(long)]
    pub name: String,

    /// JSON data as string
    #[arg(long)]
    pub json_data: String,

    /// Pretty print JSON
    #[arg(long, default_value = "true")]
    pub pretty: bool,

    /// Optional caption/description
    #[arg(long)]
    pub caption: Option<String>,

    /// Reply to message ID
    #[arg(long)]
    pub reply_msg_id: Option<String>,

    /// Chat ID (will use default from config if not provided)
    #[arg(long)]
    pub chat_id: Option<String>,
}

#[derive(Debug, Clone, Args)]
pub struct FileInfoArgs {
    /// File ID to get information about
    #[arg(long)]
    pub file_id: String,
}

impl FileCommands {
    pub async fn execute_with_output(
        &self,
        bot: &Bot,
        output_format: &OutputFormat,
    ) -> CliResult<()> {
        let response = match self {
            FileCommands::Upload(args) => self.handle_upload(bot, args).await,
            FileCommands::UploadText(args) => self.handle_upload_text(bot, args).await,
            FileCommands::UploadJson(args) => self.handle_upload_json(bot, args).await,
            FileCommands::Info(args) => self.handle_file_info(bot, args).await,
        };

        OutputFormatter::print(&response, output_format)?;

        if !response.success {
            std::process::exit(1);
        }

        Ok(())
    }

    async fn handle_upload(
        &self,
        bot: &Bot,
        args: &UploadFileArgs,
    ) -> CliResponse<serde_json::Value> {
        // Decode base64 content
        let file_content = match base64::engine::general_purpose::STANDARD
            .decode(&args.content_base64)
        {
            Ok(content) => content,
            Err(e) => {
                return CliResponse::error("upload-file", format!("Invalid base64 content: {e}"));
            }
        };

        // Validate file size (100MB limit)
        if file_content.len() > 100 * 1024 * 1024 {
            return CliResponse::error("upload-file", "File too large (max 100MB)");
        }

        let chat_id = match &args.chat_id {
            Some(id) => ChatId::from_borrowed_str(id),
            None => {
                // Get default chat ID from environment or config
                match std::env::var("VKTEAMS_BOT_CHAT_ID") {
                    Ok(id) => ChatId::from_borrowed_str(&id),
                    Err(_) => {
                        return CliResponse::error(
                            "upload-file",
                            "No chat ID provided and VKTEAMS_BOT_CHAT_ID not set",
                        );
                    }
                }
            }
        };

        let mut req = RequestMessagesSendFile::new((
            chat_id,
            MultipartName::FileContent {
                filename: args.name.clone(),
                content: file_content.clone(),
            },
        ));

        if let Some(caption) = &args.caption {
            req = req.with_text(caption.clone());
        }

        if let Some(reply_msg_id) = &args.reply_msg_id {
            req = req.with_reply_msg_id(MsgId(reply_msg_id.clone()));
        }

        match bot.send_api_request(req).await {
            Ok(response) => {
                let data = json!({
                    "message_id": response.msg_id,
                    "file_name": args.name,
                    "file_size": file_content.len(),
                    "file_size_formatted": format_file_size(file_content.len()),
                    "caption": args.caption
                });
                CliResponse::success("upload-file", data)
            }
            Err(e) => CliResponse::error("upload-file", format!("Failed to upload file: {e}")),
        }
    }

    async fn handle_upload_text(
        &self,
        bot: &Bot,
        args: &UploadTextArgs,
    ) -> CliResponse<serde_json::Value> {
        let file_content = args.content.as_bytes().to_vec();

        let chat_id = match &args.chat_id {
            Some(id) => ChatId::from_borrowed_str(id),
            None => match std::env::var("VKTEAMS_BOT_CHAT_ID") {
                Ok(id) => ChatId::from_borrowed_str(&id),
                Err(_) => {
                    return CliResponse::error(
                        "upload-text",
                        "No chat ID provided and VKTEAMS_BOT_CHAT_ID not set",
                    );
                }
            },
        };

        let mut req = RequestMessagesSendFile::new((
            chat_id,
            MultipartName::FileContent {
                filename: args.name.clone(),
                content: file_content.clone(),
            },
        ));

        if let Some(caption) = &args.caption {
            req = req.with_text(caption.clone());
        }

        if let Some(reply_msg_id) = &args.reply_msg_id {
            req = req.with_reply_msg_id(MsgId(reply_msg_id.clone()));
        }

        match bot.send_api_request(req).await {
            Ok(response) => {
                let data = json!({
                    "message_id": response.msg_id,
                    "file_name": args.name,
                    "file_size": file_content.len(),
                    "content_preview": if args.content.len() > 100 {
                        format!("{}...", &args.content[..100])
                    } else {
                        args.content.clone()
                    },
                    "caption": args.caption
                });
                CliResponse::success("upload-text", data)
            }
            Err(e) => CliResponse::error("upload-text", format!("Failed to upload text file: {e}")),
        }
    }

    async fn handle_upload_json(
        &self,
        bot: &Bot,
        args: &UploadJsonArgs,
    ) -> CliResponse<serde_json::Value> {
        // Parse and format JSON
        let json_value: serde_json::Value = match serde_json::from_str(&args.json_data) {
            Ok(value) => value,
            Err(e) => {
                return CliResponse::error("upload-json", format!("Invalid JSON data: {e}"));
            }
        };

        let formatted_json = if args.pretty {
            match serde_json::to_string_pretty(&json_value) {
                Ok(s) => s,
                Err(e) => {
                    return CliResponse::error(
                        "upload-json",
                        format!("Failed to format JSON: {e}"),
                    );
                }
            }
        } else {
            match serde_json::to_string(&json_value) {
                Ok(s) => s,
                Err(e) => {
                    return CliResponse::error(
                        "upload-json",
                        format!("Failed to serialize JSON: {e}"),
                    );
                }
            }
        };

        let final_filename = if args.name.ends_with(".json") {
            args.name.clone()
        } else {
            format!("{}.json", args.name)
        };

        let file_content = formatted_json.as_bytes().to_vec();

        let chat_id = match &args.chat_id {
            Some(id) => ChatId::from_borrowed_str(id),
            None => match std::env::var("VKTEAMS_BOT_CHAT_ID") {
                Ok(id) => ChatId::from_borrowed_str(&id),
                Err(_) => {
                    return CliResponse::error(
                        "upload-json",
                        "No chat ID provided and VKTEAMS_BOT_CHAT_ID not set",
                    );
                }
            },
        };

        let mut req = RequestMessagesSendFile::new((
            chat_id,
            MultipartName::FileContent {
                filename: final_filename.clone(),
                content: file_content.clone(),
            },
        ));

        if let Some(caption) = &args.caption {
            req = req.with_text(caption.clone());
        }

        if let Some(reply_msg_id) = &args.reply_msg_id {
            req = req.with_reply_msg_id(MsgId(reply_msg_id.clone()));
        }

        match bot.send_api_request(req).await {
            Ok(response) => {
                let data = json!({
                    "message_id": response.msg_id,
                    "file_name": final_filename,
                    "file_size": file_content.len(),
                    "pretty_formatted": args.pretty,
                    "json_valid": true,
                    "caption": args.caption
                });
                CliResponse::success("upload-json", data)
            }
            Err(e) => CliResponse::error("upload-json", format!("Failed to upload JSON file: {e}")),
        }
    }

    async fn handle_file_info(
        &self,
        bot: &Bot,
        args: &FileInfoArgs,
    ) -> CliResponse<serde_json::Value> {
        let req = RequestFilesGetInfo::new(FileId(args.file_id.clone()));

        match bot.send_api_request(req).await {
            Ok(response) => {
                let data = json!({
                    "file_type": response.file_type,
                    "file_size": response.file_size,
                    "file_name": response.file_name,
                    "url": response.url
                });
                CliResponse::success("file-info", data)
            }
            Err(e) => CliResponse::error("file-info", format!("Failed to get file info: {e}")),
        }
    }
}

#[async_trait]
impl Command for FileCommands {
    async fn execute(&self, bot: &Bot) -> CliResult<()> {
        // Default to pretty format for backward compatibility
        self.execute_with_output(bot, &OutputFormat::Pretty).await
    }

    fn name(&self) -> &'static str {
        match self {
            FileCommands::Upload(_) => "upload-file",
            FileCommands::UploadText(_) => "upload-text",
            FileCommands::UploadJson(_) => "upload-json",
            FileCommands::Info(_) => "file-info",
        }
    }

    fn validate(&self) -> CliResult<()> {
        match self {
            FileCommands::Upload(args) => {
                if args.name.is_empty() {
                    return Err(CliError::InputError(
                        "File name cannot be empty".to_string(),
                    ));
                }
                if args.content_base64.is_empty() {
                    return Err(CliError::InputError(
                        "File content cannot be empty".to_string(),
                    ));
                }
            }
            FileCommands::UploadText(args) => {
                if args.name.is_empty() {
                    return Err(CliError::InputError(
                        "File name cannot be empty".to_string(),
                    ));
                }
            }
            FileCommands::UploadJson(args) => {
                if args.name.is_empty() {
                    return Err(CliError::InputError(
                        "File name cannot be empty".to_string(),
                    ));
                }
                if args.json_data.is_empty() {
                    return Err(CliError::InputError(
                        "JSON data cannot be empty".to_string(),
                    ));
                }
            }
            FileCommands::Info(args) => {
                if args.file_id.is_empty() {
                    return Err(CliError::InputError("File ID cannot be empty".to_string()));
                }
            }
        }
        Ok(())
    }
}

fn format_file_size(size: usize) -> String {
    const UNITS: &[&str] = &["B", "KB", "MB", "GB"];
    let mut size = size as f64;
    let mut unit_index = 0;

    while size >= 1024.0 && unit_index < UNITS.len() - 1 {
        size /= 1024.0;
        unit_index += 1;
    }

    if unit_index == 0 {
        format!("{} {}", size as usize, UNITS[unit_index])
    } else {
        format!("{:.1} {}", size, UNITS[unit_index])
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_format_file_size() {
        assert_eq!(format_file_size(0), "0 B");
        assert_eq!(format_file_size(512), "512 B");
        assert_eq!(format_file_size(1024), "1.0 KB");
        assert_eq!(format_file_size(1536), "1.5 KB");
        assert_eq!(format_file_size(1024 * 1024), "1.0 MB");
        assert_eq!(format_file_size(1024 * 1024 * 1024), "1.0 GB");
    }

    #[test]
    fn test_upload_args_validation() {
        let args = UploadFileArgs {
            name: "".to_string(),
            content_base64: "content".to_string(),
            caption: None,
            reply_msg_id: None,
            chat_id: None,
        };

        let cmd = FileCommands::Upload(args);
        assert!(cmd.validate().is_err());
    }

    #[test]
    fn test_json_filename_extension() {
        let args = UploadJsonArgs {
            name: "test".to_string(),
            json_data: "{}".to_string(),
            pretty: true,
            caption: None,
            reply_msg_id: None,
            chat_id: None,
        };

        // In real usage, this would be handled in handle_upload_json
        let expected_filename = if args.name.ends_with(".json") {
            args.name.clone()
        } else {
            format!("{}.json", args.name)
        };

        assert_eq!(expected_filename, "test.json");
    }

    #[test]
    fn test_file_commands_name() {
        let upload_cmd = FileCommands::Upload(UploadFileArgs {
            name: "test.txt".to_string(),
            content_base64: "dGVzdA==".to_string(),
            caption: None,
            reply_msg_id: None,
            chat_id: None,
        });
        assert_eq!(upload_cmd.name(), "upload-file");

        let upload_text_cmd = FileCommands::UploadText(UploadTextArgs {
            name: "test.txt".to_string(),
            content: "test content".to_string(),
            caption: None,
            reply_msg_id: None,
            chat_id: None,
        });
        assert_eq!(upload_text_cmd.name(), "upload-text");

        let upload_json_cmd = FileCommands::UploadJson(UploadJsonArgs {
            name: "test.json".to_string(),
            json_data: "{}".to_string(),
            pretty: true,
            caption: None,
            reply_msg_id: None,
            chat_id: None,
        });
        assert_eq!(upload_json_cmd.name(), "upload-json");

        let info_cmd = FileCommands::Info(FileInfoArgs {
            file_id: "test_file_id".to_string(),
        });
        assert_eq!(info_cmd.name(), "file-info");
    }

    #[test]
    fn test_upload_file_validation() {
        // Valid upload file args
        let valid_args = UploadFileArgs {
            name: "test.txt".to_string(),
            content_base64: "dGVzdA==".to_string(),
            caption: None,
            reply_msg_id: None,
            chat_id: None,
        };
        let cmd = FileCommands::Upload(valid_args);
        assert!(cmd.validate().is_ok());

        // Empty name
        let invalid_name_args = UploadFileArgs {
            name: "".to_string(),
            content_base64: "dGVzdA==".to_string(),
            caption: None,
            reply_msg_id: None,
            chat_id: None,
        };
        let cmd = FileCommands::Upload(invalid_name_args);
        assert!(cmd.validate().is_err());

        // Empty content
        let invalid_content_args = UploadFileArgs {
            name: "test.txt".to_string(),
            content_base64: "".to_string(),
            caption: None,
            reply_msg_id: None,
            chat_id: None,
        };
        let cmd = FileCommands::Upload(invalid_content_args);
        assert!(cmd.validate().is_err());
    }

    #[test]
    fn test_upload_text_validation() {
        // Valid upload text args
        let valid_args = UploadTextArgs {
            name: "test.txt".to_string(),
            content: "test content".to_string(),
            caption: None,
            reply_msg_id: None,
            chat_id: None,
        };
        let cmd = FileCommands::UploadText(valid_args);
        assert!(cmd.validate().is_ok());

        // Empty name
        let invalid_args = UploadTextArgs {
            name: "".to_string(),
            content: "test content".to_string(),
            caption: None,
            reply_msg_id: None,
            chat_id: None,
        };
        let cmd = FileCommands::UploadText(invalid_args);
        assert!(cmd.validate().is_err());
    }

    #[test]
    fn test_upload_json_validation() {
        // Valid upload json args
        let valid_args = UploadJsonArgs {
            name: "test.json".to_string(),
            json_data: "{}".to_string(),
            pretty: true,
            caption: None,
            reply_msg_id: None,
            chat_id: None,
        };
        let cmd = FileCommands::UploadJson(valid_args);
        assert!(cmd.validate().is_ok());

        // Empty name
        let invalid_name_args = UploadJsonArgs {
            name: "".to_string(),
            json_data: "{}".to_string(),
            pretty: true,
            caption: None,
            reply_msg_id: None,
            chat_id: None,
        };
        let cmd = FileCommands::UploadJson(invalid_name_args);
        assert!(cmd.validate().is_err());

        // Empty JSON data
        let invalid_json_args = UploadJsonArgs {
            name: "test.json".to_string(),
            json_data: "".to_string(),
            pretty: true,
            caption: None,
            reply_msg_id: None,
            chat_id: None,
        };
        let cmd = FileCommands::UploadJson(invalid_json_args);
        assert!(cmd.validate().is_err());
    }

    #[test]
    fn test_file_info_validation() {
        // Valid file info args
        let valid_args = FileInfoArgs {
            file_id: "test_file_id".to_string(),
        };
        let cmd = FileCommands::Info(valid_args);
        assert!(cmd.validate().is_ok());

        // Empty file ID
        let invalid_args = FileInfoArgs {
            file_id: "".to_string(),
        };
        let cmd = FileCommands::Info(invalid_args);
        assert!(cmd.validate().is_err());
    }

    #[test]
    fn test_json_filename_with_extension() {
        // Test filename that already has .json extension
        let args = UploadJsonArgs {
            name: "test.json".to_string(),
            json_data: "{}".to_string(),
            pretty: true,
            caption: None,
            reply_msg_id: None,
            chat_id: None,
        };

        let final_filename = if args.name.ends_with(".json") {
            args.name.clone()
        } else {
            format!("{}.json", args.name)
        };

        assert_eq!(final_filename, "test.json");
    }

    #[test]
    fn test_json_filename_without_extension() {
        // Test filename without .json extension
        let args = UploadJsonArgs {
            name: "test".to_string(),
            json_data: "{}".to_string(),
            pretty: true,
            caption: None,
            reply_msg_id: None,
            chat_id: None,
        };

        let final_filename = if args.name.ends_with(".json") {
            args.name.clone()
        } else {
            format!("{}.json", args.name)
        };

        assert_eq!(final_filename, "test.json");
    }

    #[test]
    fn test_format_file_size_edge_cases() {
        // Test large file sizes
        assert_eq!(
            format_file_size(1024 * 1024 * 1024 + 512 * 1024 * 1024),
            "1.5 GB"
        );
        assert_eq!(format_file_size(2048), "2.0 KB");
        assert_eq!(format_file_size(1023), "1023 B");
        assert_eq!(format_file_size(1025), "1.0 KB");
    }

    #[test]
    fn test_execute_with_default_format() {
        // Test that execute() uses Pretty format by default through Command trait
        let cmd = FileCommands::Info(FileInfoArgs {
            file_id: "test_file_id".to_string(),
        });

        // We can't test the actual execution without mocking the network layer,
        // but we can test that the method exists and the default format is used
        assert_eq!(cmd.name(), "file-info");

        // Test validation for coverage
        assert!(cmd.validate().is_ok());
    }

    #[test]
    fn test_upload_file_args_structure() {
        let args = UploadFileArgs {
            name: "test.txt".to_string(),
            content_base64: "dGVzdA==".to_string(),
            caption: Some("Test caption".to_string()),
            reply_msg_id: Some("msg_123".to_string()),
            chat_id: Some("chat_456".to_string()),
        };

        assert_eq!(args.name, "test.txt");
        assert_eq!(args.content_base64, "dGVzdA==");
        assert_eq!(args.caption, Some("Test caption".to_string()));
        assert_eq!(args.reply_msg_id, Some("msg_123".to_string()));
        assert_eq!(args.chat_id, Some("chat_456".to_string()));
    }

    #[test]
    fn test_upload_text_args_structure() {
        let args = UploadTextArgs {
            name: "test.txt".to_string(),
            content: "test content".to_string(),
            caption: Some("Test caption".to_string()),
            reply_msg_id: Some("msg_123".to_string()),
            chat_id: Some("chat_456".to_string()),
        };

        assert_eq!(args.name, "test.txt");
        assert_eq!(args.content, "test content");
        assert_eq!(args.caption, Some("Test caption".to_string()));
        assert_eq!(args.reply_msg_id, Some("msg_123".to_string()));
        assert_eq!(args.chat_id, Some("chat_456".to_string()));
    }

    #[test]
    fn test_upload_json_args_structure() {
        let args = UploadJsonArgs {
            name: "test.json".to_string(),
            json_data: r#"{"key": "value"}"#.to_string(),
            pretty: false,
            caption: Some("Test caption".to_string()),
            reply_msg_id: Some("msg_123".to_string()),
            chat_id: Some("chat_456".to_string()),
        };

        assert_eq!(args.name, "test.json");
        assert_eq!(args.json_data, r#"{"key": "value"}"#);
        assert!(!args.pretty);
        assert_eq!(args.caption, Some("Test caption".to_string()));
        assert_eq!(args.reply_msg_id, Some("msg_123".to_string()));
        assert_eq!(args.chat_id, Some("chat_456".to_string()));
    }

    #[test]
    fn test_file_info_args_structure() {
        let args = FileInfoArgs {
            file_id: "test_file_id_123".to_string(),
        };

        assert_eq!(args.file_id, "test_file_id_123");
    }

    #[test]
    fn test_file_commands_debug_and_clone() {
        let cmd = FileCommands::Upload(UploadFileArgs {
            name: "test.txt".to_string(),
            content_base64: "dGVzdA==".to_string(),
            caption: None,
            reply_msg_id: None,
            chat_id: None,
        });

        // Test Debug trait
        let debug_str = format!("{cmd:?}");
        assert!(debug_str.contains("Upload"));
        assert!(debug_str.contains("test.txt"));

        // Test Clone trait
        let cloned_cmd = cmd.clone();
        assert_eq!(cloned_cmd.name(), cmd.name());
    }

    #[test]
    fn test_args_debug_and_clone() {
        let upload_args = UploadFileArgs {
            name: "test.txt".to_string(),
            content_base64: "dGVzdA==".to_string(),
            caption: None,
            reply_msg_id: None,
            chat_id: None,
        };

        // Test Debug and Clone traits
        let debug_str = format!("{upload_args:?}");
        assert!(debug_str.contains("test.txt"));

        let cloned_args = upload_args.clone();
        assert_eq!(cloned_args.name, upload_args.name);
    }
}