(
show_encoders: bool,
encoder: &String,
source_file: &String,
source_files_directory: &String,
was_ui_opened: bool,
)
| 44 | } |
| 45 | |
| 46 | pub fn standard_cli_check( |
| 47 | show_encoders: bool, |
| 48 | encoder: &String, |
| 49 | source_file: &String, |
| 50 | source_files_directory: &String, |
| 51 | was_ui_opened: bool, |
| 52 | ) { |
| 53 | fail_if_environment_not_setup(); |
| 54 | |
| 55 | if show_encoders { |
| 56 | println!("Supported supported: {:?}", get_supported_encoders()); |
| 57 | dont_disappear::any_key_to_continue::default(); |
| 58 | std::process::exit(0); |
| 59 | } |
| 60 | |
| 61 | // this means no encoder was specified |
| 62 | if encoder == "encoder" { |
| 63 | println!("Error: Please provide one of the supported supported via '-e encoder_name'; for a list of supported supported use the '-l' argument"); |
| 64 | error_with_ack(was_ui_opened); |
| 65 | } |
| 66 | |
| 67 | // check if specified encoder is supported by the tool |
| 68 | if !is_encoder_supported(&encoder) { |
| 69 | println!( |
| 70 | "Error: [{}] is not a supported encoder at the moment", |
| 71 | encoder |
| 72 | ); |
| 73 | error_with_ack(was_ui_opened); |
| 74 | } |
| 75 | |
| 76 | // determine whether the specified file exists or not; taking source file directory into account |
| 77 | let effective_file_path = if !source_files_directory.is_empty() { |
| 78 | format!("{}/{}", source_files_directory, source_file) |
| 79 | } else { |
| 80 | source_file.clone() |
| 81 | }; |
| 82 | |
| 83 | if !source_file.is_empty() && !Path::new(effective_file_path.as_str()).exists() { |
| 84 | println!("Error: [{}] source file does not exist; if you want to use one of the provided source files, download them from the project's readme:\n{}", effective_file_path, get_repo_url()); |
| 85 | error_with_ack(was_ui_opened); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | pub fn error_with_ack(ack: bool) { |
| 90 | // want to give the user a chance to acknowledge the error |
no test coverage detected