|
| 1 | +use file_classification_core::service::file_group::delete_file_group; |
| 2 | +use file_classification_core::utils::database::establish_connection; |
| 3 | +use std::io::{stdin, stdout, Write}; |
| 4 | + |
| 5 | +fn main() { |
| 6 | + let connection = &mut establish_connection(); |
| 7 | + |
| 8 | + let mut file_id_input = String::new(); |
| 9 | + let mut group_id_input = String::new(); |
| 10 | + |
| 11 | + print!("Please input File ID: "); |
| 12 | + stdout().flush().unwrap(); |
| 13 | + stdin().read_line(&mut file_id_input).unwrap(); |
| 14 | + let file_id: i32 = file_id_input.trim().parse().expect("Invalid File ID"); |
| 15 | + |
| 16 | + print!("Please input Group ID: "); |
| 17 | + stdout().flush().unwrap(); |
| 18 | + stdin().read_line(&mut group_id_input).unwrap(); |
| 19 | + let group_id: i32 = group_id_input.trim().parse().expect("Invalid Group ID"); |
| 20 | + |
| 21 | + let result = delete_file_group(connection, file_id, group_id); |
| 22 | + match result { |
| 23 | + Ok(deleted_file_group_num) => { |
| 24 | + if deleted_file_group_num == 0 { |
| 25 | + println!("No FileGroup deleted!"); |
| 26 | + } else { println!("FileGroup deleted successfully!({:?} line changed)", deleted_file_group_num) } |
| 27 | + } |
| 28 | + Err(e) => eprintln!("Error deleting FileGroup: {}", e), |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +#[allow(dead_code)] |
| 33 | +#[cfg(not(windows))] |
| 34 | +const EOF: &str = "CTRL+D"; |
| 35 | + |
| 36 | +#[allow(dead_code)] |
| 37 | +#[cfg(windows)] |
| 38 | +const EOF: &str = "CTRL+Z"; |
0 commit comments